此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; o0 {0 [6 |: L) e* P* d1 Y1 K
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* y3 b: v" T: m
方式一:/ i# }9 q& j# b! D& U
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: i- V/ {- Z+ d( Q. n, m+ \
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ [$ i3 D6 I, `3 {% [, b1 D8 o: t
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; X, I% @( z6 R1 _3 ]1 v1 {, c i0 S 方式二:+ h* U1 X6 s y; R
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: t8 v/ }2 r7 e# R/ g) N0 F
SetTitleMatchMode RegEx2 [. v3 y9 \$ i) k
return
! X9 T, d6 q y& H' _' z6 v ; Stuff to do when Windows Explorer is open4 @. L$ y$ p3 F9 [7 v
;
8 A. m6 [1 j. z; L8 c #IfWinActive ahk_class ExploreWClass|CabinetWClass
+ F9 s, `5 c7 h4 h) U# ?' k ; open ‘cmd’ in the current directory
3 G6 k# a) `+ r/ q' v ;
# s* V A9 ~& J5 D$ R) x #c::
! O0 f9 F4 ^" W( \1 j w& l, u OpenCmdInCurrent()
# e' C) h" {: g e return8 u- G% O- M: g8 @% m2 W: D, y
#IfWinActive. d# q4 b. U- p6 T0 F
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 S4 i2 Y# U4 t6 F. B9 V8 h
; Note: expecting to be run when the active window is Explorer.
6 `6 X$ e" p3 T ; b0 e' a- z# P. n6 G
OpenCmdInCurrent()
, C" N! v( a# O* R {& ]" D. e' e2 y+ T/ \: `
; This is required to get the full path of the file from the address bar
9 O7 h* r) R. C* q WinGetText, full_path, A. q; t( ], a6 D. U( G; `% w: h9 f' r
; Split on newline (`n)) W7 j& h- [! _$ B! }" v
StringSplit, word_array, full_path, `n
0 p4 \* B$ M1 A. P1 x* }& |1 W ; Take the first element from the array. K2 Z8 R7 R1 S, K5 n, |" h: Y
full_path = %word_array1%3 i, W0 v& M1 z7 p8 ~
; strip to bare address4 `( ^7 [5 J; Z W7 O
full_path := RegExReplace(full_path, “地址: “, “”)* L* C; M8 x4 r
; Just in case – remove all carriage returns (`r)
4 x% z2 I: {* @ StringReplace, full_path, full_path, `r, , all/ g( }8 C0 U) X) u; o$ S
IfInString full_path, \3 d) U1 n: Q3 J p/ ~5 y
{
4 Y; |+ I" [. J2 w Run, cmd /K cd /D “%full_path%”4 v5 W2 j+ e' v5 u v& J
}' l9 [9 L% Q' P( _
else) c5 h8 z' y4 a- t
{4 i# B& X' g. q0 t
Run, cmd /K cd /D “C:\ ”5 k* m7 X/ D7 y: z
}+ q& x0 |- F# L+ V8 c: u
}
$ |: p( A" N3 \/ E: e0 ^5 I4 m3 k 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( ~- i. T C. t( X* ^: N: E, ~
这段小代码肯能有两个你需要修改的地方7 K% W3 u% Y( y; x% t
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( n# Q7 `! H' r4 d
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( M3 N& `) v' b: u8 x# ?/ w
|