此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, j) n& C6 F6 s- Y 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 j6 G* c( ~( `# `8 r0 U 方式一:
% q5 x0 l* W- O( k. H3 X' `- I" k& s 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ X2 T( J5 ?8 L4 o9 B
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ V' A1 d* t3 F( s- W, x
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 p' W0 n* K8 ~9 d2 _- R
方式二:' E; ^: M; e, X2 O; H O9 ]2 g
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% o ^. M, F+ t. l. i( Q: t SetTitleMatchMode RegEx
1 p0 p2 z/ ]3 p: L# ^2 W! r6 V% M return, x1 w( Q! H: J0 ^5 ]. ]
; Stuff to do when Windows Explorer is open9 T) q: {$ v4 c, O
;
1 t8 V( @. P9 x, P7 Y #IfWinActive ahk_class ExploreWClass|CabinetWClass
* |9 T3 v& W. Z2 ?5 J, Y6 J9 A ; open ‘cmd’ in the current directory
$ l- u6 V8 ]) n$ d ;0 m; c, j) e) u1 \7 A6 d3 Y5 R
#c::7 L" g, Y8 {1 h, `+ n
OpenCmdInCurrent()0 ^7 Q5 e9 `9 R
return1 ]! L- @% N8 M
#IfWinActive3 ?- K5 ^. N( g) p) X W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
v6 e# C7 h# r+ D- F8 J: w2 h: F6 u0 Y ; Note: expecting to be run when the active window is Explorer.
: M6 D4 p8 Q9 U" F ;
- N' K0 b2 [7 Z; N OpenCmdInCurrent()
( }2 a! D R3 D" } {3 F* o H- t9 S8 D9 y& W) ?
; This is required to get the full path of the file from the address bar
0 P/ F4 D7 R: J2 G' d/ T; s WinGetText, full_path, A6 o5 f1 x/ t! \6 _7 f0 u' D
; Split on newline (`n)
% ]' V6 b' V8 m5 m StringSplit, word_array, full_path, `n: \" U0 Q3 C+ I
; Take the first element from the array
$ Q% g* R2 Q% r. N/ L. d+ N full_path = %word_array1%
- y' F, \- j& h- G9 P1 a) ~ ; strip to bare address7 ?( I! g. m( |: K
full_path := RegExReplace(full_path, “地址: “, “”)
* s% t: v( c" c/ j) i# g+ ] ; Just in case – remove all carriage returns (`r)
4 J% m: N# \) u% H& }5 c StringReplace, full_path, full_path, `r, , all
' y3 N# e% L7 g: v- z0 o- j, z0 ? IfInString full_path, \
: w3 M3 }# {7 [, F' n1 L" d! [ {4 g. ]* ]# \( a D: V; M/ C4 j0 q
Run, cmd /K cd /D “%full_path%”3 W7 e" X2 H7 k
}# w/ N: f, d6 P* a& s
else
' h S! }6 y% w3 u) j/ W, |# F0 F% a {
! A* A6 m" z% ?8 ?, @; v Run, cmd /K cd /D “C:\ ”5 I/ }( G" N- T; ?! s. t
}
4 ~1 @8 o( q: {$ j8 ^0 w( t* X0 `+ ] }
- i' y! [% u) b+ c 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ \$ p6 c* \7 _5 @0 v: H
这段小代码肯能有两个你需要修改的地方
* c6 C9 j, O! I! G4 {0 s- y; D4 } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( J# q! t7 U9 t: K; h5 L 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 M* b9 \, Q, I- E; O7 Y9 x |