此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 A" s5 [3 E, k1 S, P
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 q" y1 T& S/ c4 C$ H b$ k8 n7 W
方式一:
6 [5 H# A! ?5 V 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ N: {% N2 d$ c, [ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 _ `: Q7 B0 F& ?5 n: | HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ X5 s8 A$ l0 z6 J
方式二:, V# }( W) ]" a# c" y4 l& |; p* U) k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: ` O) l8 S8 P- a2 |
SetTitleMatchMode RegEx
) f" ~8 y- m# _! ?2 N2 {7 ~ return+ z5 _) ?! A3 _7 D
; Stuff to do when Windows Explorer is open) ~& [( g) X( v. M4 y( f% ]# v8 |
;
0 m% Z" m% {. `/ ]! v #IfWinActive ahk_class ExploreWClass|CabinetWClass) m; t" ]: s- r2 Y W
; open ‘cmd’ in the current directory# f& V* N& J* N1 ]
;, {4 Q& I3 N; Y7 w
#c::
; Q& V$ Z) u( Z/ k3 h) ` OpenCmdInCurrent()7 X) b7 J$ Q7 }5 n4 @) O( @& j l
return
2 e* g* M+ k* c' w: U #IfWinActive
& D# C# o3 }; t8 T2 s( d% U+ t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! z: I7 P: A( z/ n$ A6 J: K4 t, s3 I
; Note: expecting to be run when the active window is Explorer.
9 c) t$ c U5 w" s2 w ;: K4 L$ d6 ?/ G% E+ L5 M
OpenCmdInCurrent()
6 p2 P0 J4 q5 n: P: |) [0 _ {
& B/ J; a. \+ |; k$ z( r# m+ i ; This is required to get the full path of the file from the address bar8 j% S$ I" D, p
WinGetText, full_path, A5 W1 ]/ [6 K0 V' Y8 D
; Split on newline (`n)$ m/ d7 a+ a+ M L. D( I
StringSplit, word_array, full_path, `n+ @, X8 i8 o$ H
; Take the first element from the array$ W! v: L, }8 Y, x- Z( z8 u3 F4 N) a
full_path = %word_array1%
; l& ^* j$ ?& \! Z ; strip to bare address+ @8 A/ S% a5 R0 B- w% P
full_path := RegExReplace(full_path, “地址: “, “”), C5 l0 y9 r0 N# R8 P0 \# n. e$ n
; Just in case – remove all carriage returns (`r)
0 m- v$ W8 Q8 A: K( b( { StringReplace, full_path, full_path, `r, , all
$ d ~5 R, e8 F4 V IfInString full_path, \
7 [- q6 N( C$ o+ O/ e {$ J' H2 j* g" Z; c
Run, cmd /K cd /D “%full_path%”
3 b4 E& o% j2 M. F8 P- m; Y* I }3 a. i/ O& d) p
else
. ]7 E+ c, _. u, [/ V E {0 G- G$ m+ j" s" w6 E
Run, cmd /K cd /D “C:\ ”+ S: I# P$ m) j- _7 N# p
}( R4 M" b' T0 C
}
[5 a- O$ x, Z. V8 z( b 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 ^' b1 ?5 X0 \% c/ `" G# z" ] 这段小代码肯能有两个你需要修改的地方
6 u* Y5 O" O3 Y' J% | 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' Q1 Q. w& D" p/ o3 v 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. d) l9 _" |5 A! T) h% u |