此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 K7 y0 Q9 i* n/ y# g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 H( p0 a! z7 A" Y: U 方式一:
; Z4 {% D1 I& c$ a 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 _7 H M2 }( u( D( E" k 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 r9 s2 b' ~$ E4 y( B% \
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! K1 I6 k3 r3 ~7 n
方式二:% ~% I4 } s" s/ F
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 Q2 F+ {8 I8 m# v2 g6 f- \3 ?
SetTitleMatchMode RegEx
% J, n+ l" A$ `# j4 s3 J return, K s# H8 [9 S
; Stuff to do when Windows Explorer is open
2 V4 E- f5 t3 @, _ ;' }; S( F/ h9 `+ s- n4 ?
#IfWinActive ahk_class ExploreWClass|CabinetWClass4 }1 n+ p8 s- C
; open ‘cmd’ in the current directory* r8 h5 j% _* \) ?- V
;
( ~% M% @5 L; {' _ #c::% o1 u' |& Y4 n: {
OpenCmdInCurrent()
) q( n" S. a4 A) B- Q7 h) p return7 B: l& k3 @! D; m. A. C
#IfWinActive, F& o% j# C# q7 U6 H$ _
; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ D* O9 {8 |, X6 Q
; Note: expecting to be run when the active window is Explorer.# E0 S0 C* W: H' x0 B
;
3 b: f6 ~ [$ G) R2 M OpenCmdInCurrent()9 f. u- ] J3 k0 n
{
( w1 l3 m0 w0 [- W( a- F o5 B1 ^ ; This is required to get the full path of the file from the address bar
" _* U" {4 L( A0 c WinGetText, full_path, A
7 W5 d+ i) k( m ; Split on newline (`n)1 T3 a- ]4 g% t
StringSplit, word_array, full_path, `n
' c$ \0 h+ d6 ]9 O2 a! m ; Take the first element from the array" K9 Z8 i5 }" V$ _( @/ j
full_path = %word_array1%
% Z/ J$ j& }1 s ; strip to bare address; l8 M- P1 d7 O! i- @: t6 P+ U
full_path := RegExReplace(full_path, “地址: “, “”)
' K8 b, K6 T5 W! l ; Just in case – remove all carriage returns (`r)4 x$ t: g- L: r, r( G( U
StringReplace, full_path, full_path, `r, , all
' S: F$ v! ]" v; a, Z IfInString full_path, \
5 z1 \5 k4 p! o$ z {3 P4 ]9 P$ ] W9 Y
Run, cmd /K cd /D “%full_path%”
5 X" E$ j% @3 X1 l! r* B$ _2 \ }' Q% P2 |% t, k1 ?- V
else' ^, P. P2 F* P# j& t7 u
{
3 o: o5 D$ U) g6 S" D Run, cmd /K cd /D “C:\ ”
/ o/ k! n+ D& K# U4 F' D }
9 |5 w6 V7 ]0 C6 `1 e e }- V! c( n# Y1 ~5 H+ H' w: O0 ?" j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) |2 z- a% B% o! I9 v2 D
这段小代码肯能有两个你需要修改的地方6 j6 n2 n: J1 n. L$ f8 E
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 w+ c6 U. e# \) h 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" p( M3 M& o# } |