此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 k) A: s2 S. c# Q8 ~& O 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, P# n/ t/ I7 J 方式一:& ]. c3 u, x0 Q4 i2 i! H
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& ~9 R' H& c6 t* @4 c 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' {3 V& M1 y$ }( p/ m9 P4 L9 u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 K/ o! U. P7 I0 E; t) r# C8 ~
方式二:
& b& P$ w6 c6 u3 a 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( I9 v8 ~4 j P% A. H; H G$ @
SetTitleMatchMode RegEx
5 D5 w" ]; b/ i1 o! ]5 X! } B4 i return9 J$ k6 N' J0 R; T% K1 x/ F
; Stuff to do when Windows Explorer is open
& P0 [* J* L" ^/ h# |, j' | ;
9 u4 U9 Y. U' @ #IfWinActive ahk_class ExploreWClass|CabinetWClass
# p& M2 S/ F$ k( W3 E6 [+ G ; open ‘cmd’ in the current directory
; @7 I1 J2 p/ V4 ? ;
$ o+ G2 t0 o4 B- ^, p #c::
/ ^8 ]: N X6 C4 X& ?+ o8 t+ |3 [ OpenCmdInCurrent()$ i: ]# F9 b9 Z; ^
return
" K3 y5 v) ^ r, q% L. z8 a #IfWinActive8 J* u1 @/ t- v, q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* |% Q& K; A4 g* y
; Note: expecting to be run when the active window is Explorer.
1 o: M$ ?6 b$ q3 Q ;6 ~* J) n% m, N. l3 o, h& l
OpenCmdInCurrent()
3 ^4 \* w1 k( s' I. C0 C {
0 i0 V+ C A+ E& S. _ ; This is required to get the full path of the file from the address bar2 t1 q. R0 _: [8 b- p
WinGetText, full_path, A! n! h5 s7 c) @. G9 u4 v- n
; Split on newline (`n)
; K& j& _' ~% @+ @; S. N StringSplit, word_array, full_path, `n
# @' N, p" H T1 Z5 l% U3 w ; Take the first element from the array# e0 x* J% T3 ^: w# @
full_path = %word_array1%
2 C# ~" u5 _' E0 i9 u4 Q ; strip to bare address
8 S/ ^4 u, K8 O: {1 H) j full_path := RegExReplace(full_path, “地址: “, “”)2 u0 [7 a0 H% Z: f4 a$ W
; Just in case – remove all carriage returns (`r)
5 X9 E u; g* O; e$ {! E StringReplace, full_path, full_path, `r, , all
$ l) L: W! E2 e; y* u" e5 a IfInString full_path, \
G) \" [# S4 C3 W! g% }# G, z! p$ \ {. P4 Q$ U/ \' E1 s: J7 K
Run, cmd /K cd /D “%full_path%”% z3 N# A: f; a# K: K0 w* c
}
/ v$ L2 _9 R3 c+ c( `! ~, J, U# [ else
6 L+ W; y" X6 H: X( ?8 S1 H {1 F+ P2 X7 E! h* j
Run, cmd /K cd /D “C:\ ”
) k- ^) X& H ` V1 r }/ m) Z- d7 R# P
}$ \9 E! H" u9 E
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* c7 Y- U$ f0 m3 a- g W9 y 这段小代码肯能有两个你需要修改的地方
" Y& i/ T5 {" _7 O 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% a c( ~+ U& k5 v$ F G6 f
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 A. Z; G9 c2 a# Q
|