此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ X( X+ ~' J, M: b' z1 w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 C6 ~# q* e& e7 W4 y* n
方式一:
0 V' p4 }; z1 I9 B6 L% B$ x) @ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 n7 r) r, j/ l 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# F4 o, Z! h3 G HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' P4 E! k/ C% ] T* j u 方式二:
5 O# Q* P8 @0 E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 G( F7 P O5 u; |# n2 k- p5 } SetTitleMatchMode RegEx! K, n' j; v+ U! S" O
return8 a/ M+ }2 {0 t, D' G7 G
; Stuff to do when Windows Explorer is open
/ l. S- Z7 r$ E) z! g1 a8 O6 E8 U6 S ;0 ~% f. \# e2 A7 f
#IfWinActive ahk_class ExploreWClass|CabinetWClass: P: X3 A' v; y8 T: H. w3 V* y! m
; open ‘cmd’ in the current directory! F6 C) D* Z$ K/ T5 h2 G
;+ a$ C# ?; e7 \
#c::8 r. J$ _+ ]/ O
OpenCmdInCurrent()
- F9 q. d* R" l6 l( I return
; N( f9 v) I0 ~' P2 a6 S) ?7 b" z/ R #IfWinActive
* [0 e- a6 k- I7 M) L4 {1 Z5 |2 Z9 B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" a, N; f' n; }8 S; i" S9 h ; Note: expecting to be run when the active window is Explorer.
3 S# @# u7 P: y) K. D! [) Z7 L ;
' O) u# k# I0 W& R9 m OpenCmdInCurrent()
w* ~5 e3 E& I+ x& ~) B n {. e* h& k1 E+ d& |
; This is required to get the full path of the file from the address bar2 A! w2 T( R+ S X; p, e- L
WinGetText, full_path, A
" {- _1 P }" Z" @1 _ ; Split on newline (`n)
6 @7 x+ g; Q, M C/ V# g0 n2 v StringSplit, word_array, full_path, `n
+ {* ^% h% h- f* a ; Take the first element from the array
7 Y+ `4 v, L% J4 T- T* @ full_path = %word_array1%
7 ~4 `" E( q1 {% C( W1 y! D$ Y3 v ; strip to bare address) b1 E9 }6 ]; b# A( h* d1 f
full_path := RegExReplace(full_path, “地址: “, “”)+ g c. e, I! g/ E/ M! _
; Just in case – remove all carriage returns (`r)
0 I+ ^) s/ Z9 `% v5 r. h4 A4 O StringReplace, full_path, full_path, `r, , all( x' g h: }6 ^. G3 G) E
IfInString full_path, \
6 c* Q/ T( F& F) b9 R- c+ l( D {3 P }# @* j! d
Run, cmd /K cd /D “%full_path%”8 B' s3 O, I9 [) n s5 W1 ]
}* F- [; ?( E- X" Y7 Q
else
, e9 h" U" v9 e; Y1 ] {4 [$ W, C( e5 d$ H
Run, cmd /K cd /D “C:\ ”* s r8 e/ y6 a9 ?, [6 M
}! K6 U1 E) Y3 q3 P: h& ^. a
}
9 l: Q4 Z$ L" s9 ]) Q+ p+ A0 n$ T 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' Y. ?4 W* e7 w; o. \' w
这段小代码肯能有两个你需要修改的地方
& f' z7 R) C+ I5 m& ]- K 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& ^2 x/ W0 m1 }3 G/ g 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 @( I# D% m# k! K7 A- S- s |