此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' k' d9 ?; f0 B9 j6 J% N 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% u, J4 T! J8 ~$ L) \ x
方式一:+ d* y! R! f7 f
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) g. _; G4 s Y6 _
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 e7 E3 A3 M5 W8 W5 f2 R HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 f+ f! `! I0 o. j
方式二:; l) p) ^+ T8 c5 K
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' C# L% w5 \- `5 k) W
SetTitleMatchMode RegEx s6 y- Q- m, j+ A
return
7 r: o8 T C) A4 L1 u; F ; Stuff to do when Windows Explorer is open& B9 ^& }/ M* m8 @( a9 W1 g
;
: Z% }/ i! o; t% N d #IfWinActive ahk_class ExploreWClass|CabinetWClass
, G& i( Y$ ?) R& i% a) E" { ; open ‘cmd’ in the current directory# h; K, T& p2 G' x x6 T
;3 y. c: v2 V/ c6 {$ b- }8 \
#c::
/ ^7 t. e( c7 ]5 n OpenCmdInCurrent()$ m& _. g- B9 M7 B7 D# m' P# M" z
return' ?3 f' N$ T, A( o0 L4 x
#IfWinActive- O$ }. {, a( b0 w. Y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: `' ]9 t+ ^! o. E ; Note: expecting to be run when the active window is Explorer.
# Q# ^8 |# B, z" K# H. w ;9 ~) X. r0 Y8 t& l. s& g. a
OpenCmdInCurrent()" d: o$ I' R S' m/ [0 Z; E* I
{
/ d' j8 h9 k) L# T4 q ; This is required to get the full path of the file from the address bar9 l4 X( W9 E1 R# ~2 f8 i( P( w. U
WinGetText, full_path, A
# e7 T- \8 p! v& c! S ; Split on newline (`n)/ ~- E; ?# o% U$ { r5 q; L
StringSplit, word_array, full_path, `n
6 }. }3 M% [3 R. A" L, r* u7 q/ a: S' z ; Take the first element from the array6 ?" V, V0 M$ O: H
full_path = %word_array1%
5 c8 ~$ D9 `2 B7 ~: T ; strip to bare address
% e1 j+ v8 h; Y9 o3 {) z1 ]9 E' J5 ` full_path := RegExReplace(full_path, “地址: “, “”)
) g6 x2 _ D& x9 V, m ; Just in case – remove all carriage returns (`r)9 U4 I/ D) R9 T6 z! }9 v" Q" I
StringReplace, full_path, full_path, `r, , all
# T q9 S! T. Q; ?) P: H IfInString full_path, \
! v0 w7 M- v% @0 F {% X S+ c5 s9 x4 } O, R4 [
Run, cmd /K cd /D “%full_path%”
' e7 A& ?; k* F; `8 g }# B5 x$ O5 Y: K% ]- \
else
6 u' U. z. A- P# l" W, t- H {5 Q0 D) l: E6 l& l, ^ P6 \9 a* F
Run, cmd /K cd /D “C:\ ”
9 f" @2 t# s) X3 K% u }
+ _$ j% I; K) O6 X$ Z }4 ]2 }& g6 M2 N* ?+ H
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' M4 R Z# g" b# g% Q( d F 这段小代码肯能有两个你需要修改的地方
$ O7 X; d2 j) e8 l! V 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 I( {, E3 u9 s) O
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 H* d) J8 A3 F/ O4 T |