此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 ]3 I! \+ k4 W; C9 e- t: G& m ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 S0 s. C" ?# J/ R
方式一:0 a$ \, r2 }/ @& F
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( _7 K) h% m; B- \9 U4 r( N/ V 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, P. Q5 V8 v, D4 A5 j7 l' @ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ K8 R/ g; U, N- R8 { E- [ u 方式二:
4 ~( X6 g$ D9 E, ~ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 N& J6 W* ?( H2 \
SetTitleMatchMode RegEx! U1 d. |6 q) \+ L3 p
return
4 z. D' n s2 j ; Stuff to do when Windows Explorer is open0 }" D- [/ ~4 {
;
. ]" G& ], |3 \9 \$ n+ L% C #IfWinActive ahk_class ExploreWClass|CabinetWClass
# G! M; z# h0 s5 c ; open ‘cmd’ in the current directory' {$ e- j- h. r1 }$ i+ J+ P
;
: c$ n" h4 Z4 \; C$ ]& }. e #c::
: q9 H( h& _, q% x* k% R# o! B OpenCmdInCurrent()& j e" G* a6 f7 r0 X! z
return
" I+ I3 V2 e8 T: f1 q# _2 C #IfWinActive
# j0 w& q+ p n7 q' A ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 i' B6 U; ]6 a4 v+ S7 Q, \% |
; Note: expecting to be run when the active window is Explorer.' F5 D+ L; z6 V+ Y
;
/ L8 V2 ~2 B- F: o OpenCmdInCurrent()8 N; g6 k4 a7 f3 M b
{
3 p7 D8 w y7 I ; This is required to get the full path of the file from the address bar/ t/ I" H, b w) I6 X% @
WinGetText, full_path, A! e$ N- w8 n7 Q( q1 r2 |0 g. q
; Split on newline (`n)
( o5 A( J; z6 S6 \+ N. I StringSplit, word_array, full_path, `n
4 N9 Y5 W2 O6 ]& R ; Take the first element from the array
, M7 [+ |* Z6 W: M. [. O( i0 t+ F full_path = %word_array1%/ [: d- C G. n- I3 o
; strip to bare address& k& ?8 G f( w9 Y- `$ S, q
full_path := RegExReplace(full_path, “地址: “, “”)
) h* r' n) F [; Z$ N5 C ; Just in case – remove all carriage returns (`r)' C" g- I! E% g3 |
StringReplace, full_path, full_path, `r, , all1 G3 J! U! x' m
IfInString full_path, \
/ r7 H t) k# P' Y* Y/ z' d3 d {
+ f" A3 q2 {+ N0 b4 P8 | ?( Z4 M Run, cmd /K cd /D “%full_path%”" h+ D. J1 ~9 b8 s/ q4 `
}& p- c9 p1 v) \2 m a# g
else
' T8 o$ B, V2 u& A: |& X9 D: [* v9 k {* \, g( S# Q t r# l( R2 u. c
Run, cmd /K cd /D “C:\ ”
% H! s% ]3 N6 k0 | }( W2 @0 ]8 M C) Y$ {3 `
}
& t- j8 J( A" w! @9 U5 d 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ w% B6 T5 n6 q2 @) ^
这段小代码肯能有两个你需要修改的地方
1 {. V7 E+ m! Z! h3 h, ~ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% R2 r# ^4 D5 C4 S- j2 m! E6 o( O5 f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 ~# @+ A+ a- Y! W6 t
|