此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ j E, B8 O1 [4 S! a* P% O
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" G* m5 Z1 t( g; Z
方式一:
/ K5 W; S1 L) ~" h9 c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- W0 a# x; T5 m 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 A! D: i1 i0 f" s0 A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ p" y. ?- B/ W0 j8 x; u
方式二:3 t( j7 c/ Q4 P, ~: W6 u/ q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, [8 ^# X- k. p! N% C0 d
SetTitleMatchMode RegEx2 L1 {$ R% V# g' ? \5 b
return
$ c8 l4 l+ B0 }& C- V a ; Stuff to do when Windows Explorer is open
7 W& `( h2 k& G; h3 V ;( [# l: s- E' u3 N, w X6 N
#IfWinActive ahk_class ExploreWClass|CabinetWClass8 L H, E: D0 Z1 h
; open ‘cmd’ in the current directory+ r* N, r# M* l4 @' I- {+ x
;
$ ^2 z; e/ g2 d2 k #c::
' k' v4 W: A) C e. H OpenCmdInCurrent()
' h4 ^3 Y+ h0 U9 H return
, @( q- M- h* S6 R0 E# G; T# n8 W #IfWinActive5 G. c9 {- u% @# z2 ^) j# E+ l: }
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& B( A. Z) k) s4 K ; Note: expecting to be run when the active window is Explorer.
6 @/ O: B1 D+ M9 X ;
- A5 T8 Y7 n$ C& Q/ m; A1 o OpenCmdInCurrent()" X6 @7 n+ q6 O% J3 s8 T# ]& X% I6 E
{' ]: T; R7 T! m* O5 H; y
; This is required to get the full path of the file from the address bar9 w% }4 @ g8 f: C
WinGetText, full_path, A! Z& L3 v% |* a# b' f# d- ]
; Split on newline (`n)4 ]9 b& _) N( v) M! g6 B9 t- b
StringSplit, word_array, full_path, `n
1 m5 S8 t8 ^" T/ j) M6 }4 [ ; Take the first element from the array" n* G, X- n r0 W: d7 q
full_path = %word_array1%
% e* p! g6 ?1 D w ; strip to bare address6 d0 `5 Q+ V& ]
full_path := RegExReplace(full_path, “地址: “, “”)
! S j: ]+ f6 j, U2 X( C ; Just in case – remove all carriage returns (`r); t( R. T0 y# \' g. [
StringReplace, full_path, full_path, `r, , all
0 z1 m+ C9 @3 {; V( K IfInString full_path, \
0 a& }( a8 {$ Z# P" O, ^ {
}' t X. r/ n3 c* @ Run, cmd /K cd /D “%full_path%”' i- R* v* u9 z: I; O
}5 }8 V! B$ G& ~. Y& K
else
) h+ u7 g( Y, k& B; j: E- q. m$ u4 E {) Q; C* n: c2 [: p9 O" f) D
Run, cmd /K cd /D “C:\ ”; D; E! Y7 O$ H9 Z" R2 d
}; ]; V& `" h" Q- F& I
}
3 s! \* }" R: D 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; P; @# Z6 r J0 [3 \4 P
这段小代码肯能有两个你需要修改的地方
& S2 h' n1 h; e, I 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ H, V' |2 S# v1 u3 J2 i8 c 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 @! ~# [. `3 X+ p* g |