此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, ~0 P/ m3 D$ |( _; f2 N 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* U: q1 J0 o/ G8 A8 l3 M6 S( k
方式一:
9 [6 ~& K0 }% ]+ [: w% M$ _7 z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. D' i7 O0 \! H m8 E 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 U9 K, k4 d0 w ]' N+ ?( ]+ g HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 j0 _2 Y; Z# k
方式二:( t8 G+ t4 U- Q& z- q6 ~
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ [1 ~+ i3 F- t
SetTitleMatchMode RegEx
1 e: A0 G3 q- u return
) d* S8 X" c T% j ; Stuff to do when Windows Explorer is open
) K f4 J2 }" ^ ;3 I" K- w3 [ }- r
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ r2 _5 ?4 b9 S% [2 t: P ; open ‘cmd’ in the current directory4 _0 Z7 F, W# H+ v& R l7 V
;( Z) f7 h# d4 a5 k' y$ t
#c::
* l& ]$ e9 J8 r- ] OpenCmdInCurrent()
/ r7 z# h% d( m4 j6 _4 A6 S3 ` return
[9 w5 t. o0 M6 l- k/ C #IfWinActive) x! b6 k, I; s5 q# q. X
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ p7 ^5 @- K; B- r- \, T6 L
; Note: expecting to be run when the active window is Explorer.
- K$ w) |8 X% o! n- S8 D9 u7 y ;
, C( d. ]) s2 h4 l OpenCmdInCurrent()( B& ?: M# H1 D5 n* i
{6 Y$ P) J& v& ?' N+ Y; T! c) L
; This is required to get the full path of the file from the address bar
0 Q2 n' F# h( D0 h4 H" u( m WinGetText, full_path, A7 C+ A. Z/ r8 z) _+ F* S
; Split on newline (`n)
; K2 d& `- E1 y StringSplit, word_array, full_path, `n
h& N' {+ L4 G3 Z% x7 v; e) l, U( d ; Take the first element from the array) K3 v3 J8 m& C4 R& A# F
full_path = %word_array1%/ q$ E8 d% g5 Y! U! L' f; B
; strip to bare address
$ x9 R$ i( E' ?, O0 _( b- `& a+ C' G full_path := RegExReplace(full_path, “地址: “, “”)( [5 b( |5 \% F0 M
; Just in case – remove all carriage returns (`r)
: z- [& d; G) D j StringReplace, full_path, full_path, `r, , all
! X' K5 \6 M$ m" r) V, A IfInString full_path, \
* N# u1 M: _# N1 u8 o {
" n% S+ V9 c- n4 t, i' L2 { Run, cmd /K cd /D “%full_path%”2 W ~ [$ C/ s" @2 w6 j8 J/ o- A0 \5 {
}/ Q7 r+ d" L( h3 r/ S) m
else
) j) Y" ?( U5 [- }) ~- b) m: X- z {* |# J+ \* ~/ Y# k( ~2 Q+ m1 A, Z& j" s
Run, cmd /K cd /D “C:\ ”. N+ K- w! C+ p: H2 Y
}
& h. P6 E) C. ^. t6 y }
/ y: ^% k* a+ U1 U5 i 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! O& [% e# {9 X8 H7 i
这段小代码肯能有两个你需要修改的地方4 b. I) D1 [& G
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) ^( |1 ^5 O# G. c) q% M
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 R2 ]2 y$ g$ H) ^' T' s2 C$ k
|