此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 K; g* h" t% W" {; [+ z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 S) P; b+ @* m, R/ H 方式一:
+ Z/ e/ }$ o* u* i+ @+ p4 p' \# U- } 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
z; q: d% @) i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' n+ N( M% K- X+ W. E# {; k1 X+ n4 M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 l5 G+ i. Q* m4 F) t3 K
方式二:/ I0 S! a; ?" E
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# q8 I5 ?5 z% p) P8 d' ~3 f
SetTitleMatchMode RegEx
' e6 Q8 R- U1 Q! W+ T5 k d/ M' s, V! X return
, b0 _" j( h- K9 R& Y: G O- L% V& e ; Stuff to do when Windows Explorer is open
9 L( l! w( t$ @. r) ^ ;
3 N2 N A7 o& z: R& Z' N+ B #IfWinActive ahk_class ExploreWClass|CabinetWClass
. {* {. e# i1 V: y. H0 S$ o ; open ‘cmd’ in the current directory
/ ?$ ]+ F* d# |7 O) r3 A( b: k ;1 Z0 g, D y$ t( l5 n0 @
#c::
9 ^0 ~; H* R+ {& n0 b OpenCmdInCurrent()
# {1 r, [& P3 j: R return) F2 d# U7 _! `* v. _" N' C
#IfWinActive
0 w" b9 W1 b3 _0 \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; _8 O a; N! J/ W1 s ; Note: expecting to be run when the active window is Explorer.2 Z1 }! @: z x
;% P* c4 l3 i7 t, w1 V2 ^
OpenCmdInCurrent()
1 G: G3 W) E0 l {7 l9 W/ ]/ v/ E _: m4 t4 ]7 p h
; This is required to get the full path of the file from the address bar, ]& k* e# d" m9 M+ [; o& t
WinGetText, full_path, A
]8 C3 y- [, S- r# D S% Y ; Split on newline (`n)
6 Y% }( f5 s/ J* {; [9 k8 e StringSplit, word_array, full_path, `n/ n+ i8 c" W8 M5 ~4 E; f; S4 }
; Take the first element from the array4 k/ ~1 N8 G$ V0 o) h3 C6 `
full_path = %word_array1%
. d/ [3 b. T, E2 ]: h7 _4 ` ; strip to bare address
1 Z1 J) L, |, v+ {0 k* d# _ full_path := RegExReplace(full_path, “地址: “, “”)
/ `" K2 p; W7 o f- G ; Just in case – remove all carriage returns (`r)
1 D( ~9 J: ^ n( I- c% p" W StringReplace, full_path, full_path, `r, , all
6 j0 f9 h. Q7 m' g/ } IfInString full_path, \
* s3 S! G! c4 S {
5 z* t4 k7 ?( f Run, cmd /K cd /D “%full_path%”/ u/ J& J" O _6 n
}; F) Y$ B9 K3 @( B& z8 ]" w
else
: x- Y' \2 v# @ G! C6 } {
: ?0 B, j( w! s4 ^- u0 g6 r Run, cmd /K cd /D “C:\ ”' D2 C% K7 P9 @: A" c4 `
}5 s+ |, V1 s. L) n/ u
}. _+ u0 q0 i: v/ N
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 _. X3 }; O. H$ S6 n6 O3 `" u
这段小代码肯能有两个你需要修改的地方8 E q- t; \5 b0 o
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 z( H: e9 [9 R- o& Z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 Q3 R% C& _3 M |