此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# Q/ B* e8 \ z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 J( a# Z! m, x: Q. ~
方式一:5 u" l: k% y% j7 M. v9 x( u
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 x2 \% @- c/ S0 v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 ]* `) h: a1 N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% c# ]' p2 O9 e 方式二:
: \5 V, e2 a) v$ n) c# d$ e6 Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: w( x) }; n5 e2 p SetTitleMatchMode RegEx' Y! @2 |* k3 X0 P$ H
return
# b, P, a, A/ D ; Stuff to do when Windows Explorer is open
) i/ x8 o6 E3 p8 n3 E$ H ; \& n l, i& y) W' c4 f# z
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ e, M; o& H9 w5 ^ ; open ‘cmd’ in the current directory$ v% g* W7 q& j9 t! Y* k" B
;
" `" T# g& V, E. e #c::
1 l ~; a- b1 Y+ y' _; W1 J+ d OpenCmdInCurrent()9 Y' }3 c* J$ U
return$ s+ b1 a, l4 d/ m; O5 @
#IfWinActive
9 x8 o- f6 n& l; v( C ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) _ A3 m2 i% U3 p0 X; T. e ; Note: expecting to be run when the active window is Explorer.' V% n$ N/ D& {8 U
;. \" n) C, a) L) o$ z+ {
OpenCmdInCurrent()# i5 ~# W! R) Z# ?$ |
{- O" X2 o4 C- c. S/ V8 h& F0 N2 T
; This is required to get the full path of the file from the address bar
7 ]4 `/ l$ \( j2 q2 x! H! Y8 f WinGetText, full_path, A7 x h* v0 f; Q2 |% [+ Y
; Split on newline (`n)# n2 l* E7 a. u$ x
StringSplit, word_array, full_path, `n8 c/ {" W, r: l6 c
; Take the first element from the array6 G3 ]" T* |- Z+ w1 w* b
full_path = %word_array1%
' c4 f& Y# U" B% A! ^; H$ N ; strip to bare address$ V: U5 m- T& O) |1 r- _, H
full_path := RegExReplace(full_path, “地址: “, “”) e, r" R/ ^' ^3 S0 u% s7 D4 q6 \
; Just in case – remove all carriage returns (`r)
, l& Q. f- R3 y* Q+ Y2 \) G StringReplace, full_path, full_path, `r, , all/ o9 {2 a/ w9 r2 [9 J* c
IfInString full_path, \
1 n0 U, N% i( {! E) w {
' l# y8 ]( R. j5 X9 F1 Z$ P Run, cmd /K cd /D “%full_path%”
& f2 I. f# G* I% i% v }
6 f2 p" ?$ A3 [; q4 F else
& Z( M& A1 K5 @* U d/ x' e1 ^ {
8 X* t2 K. c: _* G Run, cmd /K cd /D “C:\ ”8 F2 q1 W1 `/ M) X7 l3 U
}
3 f) D+ G2 \; B# g% H+ x+ t, A8 x0 O }
8 H! ?. ?! [. K v) ?( S: q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。, {, J8 y) g) \! _8 i
这段小代码肯能有两个你需要修改的地方( {* q/ i% u1 Y# F7 h: B
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! P" B: l8 I t9 g2 k1 X
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- @: o& R# O9 m y& u
|