此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; J2 y. {2 ^( ?# L
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 k; q5 n. T c2 z) i# Z2 {
方式一:
% |% W# ?( u, ?5 _) k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 l( p8 L D1 h+ x5 H& |. c9 D 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! s9 h+ Y; H- B+ Z! a; w8 _
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 ~0 [6 N0 H) d6 t* l6 d8 ^% q
方式二:
: K8 l5 l# e4 P) i" b' |( m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ T% K4 ?3 T+ ` SetTitleMatchMode RegEx3 `5 ]/ h9 \; ?+ y' j, Q
return+ w4 r: f0 ?0 x' ?1 z
; Stuff to do when Windows Explorer is open
3 Q% r W) Q' v) p ;
# X6 p8 c6 P- U" r" Q ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass( S$ p4 l" _: k# K4 p& s9 X
; open ‘cmd’ in the current directory
5 Z- j( `1 l# P( k! D3 ^: t: J9 S ;3 ?2 t( f! ?2 ?, o3 T
#c::
' B3 \! ^2 p7 P& @8 s8 B OpenCmdInCurrent()
$ H. F, m+ v. [- U$ C4 R! s return* `. G* r/ k% ^6 v q% P/ U
#IfWinActive: C( M- o* Y o T
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; U" s* Q$ h- i! [6 R; y0 N; J
; Note: expecting to be run when the active window is Explorer.. S# p& c* x7 s$ b6 Z3 r
;
: o8 K& ?6 \% C OpenCmdInCurrent()3 f2 A, A0 N7 U9 m
{7 A# v" w: S: S: H
; This is required to get the full path of the file from the address bar$ S) [. J# w1 Y, A a' ~. A) A. F
WinGetText, full_path, A& E2 ?* {7 t6 O/ M& ], Z7 j4 ^" K$ m$ Y
; Split on newline (`n), W4 k; B( F; E" ?6 |, y
StringSplit, word_array, full_path, `n2 b2 ~/ J7 \' ]3 y2 X2 b
; Take the first element from the array% m/ z, L' b+ ~ O p
full_path = %word_array1%8 n z9 P; G6 U. ]
; strip to bare address, R; B& Y" R) }; x
full_path := RegExReplace(full_path, “地址: “, “”)) s7 M7 {/ g( ~8 `/ g4 {5 ~
; Just in case – remove all carriage returns (`r)1 c* I7 B+ _, R# B
StringReplace, full_path, full_path, `r, , all( U! ]2 q& |3 N& L. ^. F/ h2 J
IfInString full_path, \% Q# x1 \) y9 G0 k
{$ j3 \$ s/ q# O8 l, P. q
Run, cmd /K cd /D “%full_path%”' t+ ~- N& W- q# p
}
2 W7 _' X7 F# L4 C else7 c3 x0 H* U8 A( k4 u3 e% |
{
9 p8 ?" m* d j6 R Run, cmd /K cd /D “C:\ ”/ l# I2 v4 Z& }' o! ~7 q# I: J4 h
}
; g* T) i1 M" B6 s o3 g! h- C h }
" `# J4 G4 C/ {, a% q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 ?. _7 Z* W1 v 这段小代码肯能有两个你需要修改的地方# q% n6 B0 z9 V; N0 L2 {1 e
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 M. P- s' H1 T
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' ^5 p; a! ^' g4 D2 s8 ~ |