此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ o2 L% I1 H! ^ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ u4 S( G; x, N3 V+ p$ j" `
方式一:
; n0 O' r2 s+ r; | a0 ?3 t 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 o5 n) ~! \* Z$ l
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. a' X( K: b2 V! ~& Z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& p! D% ?8 P/ C9 |8 S* H S9 n 方式二:
1 d7 Q! U; h d1 Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 _, \& M) [' f( v+ z; M7 c1 E3 ] SetTitleMatchMode RegEx
* m" G0 s) |8 i( M% N; d return7 m* Q5 W; k4 K \ E/ [9 U
; Stuff to do when Windows Explorer is open
4 ?5 j0 F. I, W. l ; M# C7 C, g4 ~: }/ P) i8 e
#IfWinActive ahk_class ExploreWClass|CabinetWClass( }* R! h( J8 s) A$ p W3 i0 {) V
; open ‘cmd’ in the current directory
0 R8 q6 ?( i5 L7 D3 d# B ;' E7 A) @. a: f% p( u
#c::" w0 I0 B: s) K4 Z) ?) C
OpenCmdInCurrent()
; ?8 V$ k$ Q0 u8 B: N- k$ F9 G1 Y return
1 p" ~7 K8 Z g$ J: {/ t; o #IfWinActive
1 J( t0 F7 C8 m; M) O) Q) T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' \3 l! a; a3 T9 P! q7 h1 ? ; Note: expecting to be run when the active window is Explorer.
2 t5 h' |8 S/ i6 l8 _- C/ h' K% o ; S3 `7 I% g4 x0 ?; H
OpenCmdInCurrent()
0 e& j* j2 O @* z {5 O* X8 L) s C9 {6 E2 z; ~
; This is required to get the full path of the file from the address bar6 v$ U: D8 Y" |! w
WinGetText, full_path, A
/ \8 J9 x% L1 V8 e% G ; Split on newline (`n)
& ^. `9 s) M, q) c9 H3 p StringSplit, word_array, full_path, `n
; w5 g& P/ U& d9 d ; Take the first element from the array
E8 C1 Y8 A) K/ Y- S9 n& A2 F0 @ full_path = %word_array1%
$ Z& S' _$ p2 h" ] ; strip to bare address8 ?4 a ~* F6 G0 l0 K
full_path := RegExReplace(full_path, “地址: “, “”)2 i4 B- T/ C! z3 ^. D$ s) q, Z
; Just in case – remove all carriage returns (`r)( I; Q' R4 \ K/ g+ R
StringReplace, full_path, full_path, `r, , all7 E/ h5 T/ t! a) y3 C
IfInString full_path, \
5 K( ]+ N. E5 O0 b {
- W% ]5 |# M% \' O# I* t% S Run, cmd /K cd /D “%full_path%”3 b, D* R& r- j+ T0 p( ?
}5 o! R. o" f5 G; t4 h3 D4 I
else
0 o! I* k/ P& _ {
' K2 T2 q( H; Z' ]3 a Run, cmd /K cd /D “C:\ ”
; [2 q( {( T/ U( p' I" C }; |* J' P' \. L1 f3 K8 d
}
7 @0 W- S, A. a; I6 y. B! a- g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" z# M; q! C2 P! D( L 这段小代码肯能有两个你需要修改的地方
" F. k# R( a9 N: Z6 R 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( a$ E ]* u! V, T: P 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" b+ y; I: R, z |