此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ ], l: m4 R7 S/ @ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" S# z& y8 @, a$ _2 ~" m1 `4 G
方式一:1 z6 m8 S! m2 v
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 J$ @1 b9 r" J4 E% J
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 M& i) T# q9 M) Q9 V5 v HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! w+ z8 s. X( ^! L$ D0 q 方式二:
. d9 T, g O, s/ p, k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: {$ d/ _" \: q
SetTitleMatchMode RegEx, x9 P) ~6 j) _$ Z# h2 }
return
3 W6 A# ]1 G2 w% X- c5 |/ ]1 ~% U ; Stuff to do when Windows Explorer is open. L2 _/ G$ [. g- I- D
;- q' U& F' x d' |; Z8 e
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 b, u F8 U+ I* @2 J- L& t
; open ‘cmd’ in the current directory n9 P+ k+ p& A( y) S6 m; U
;, V: _& N0 K# \! y' ^1 r3 o
#c::
+ s6 ~7 R* G5 l* z2 l OpenCmdInCurrent()
! h8 r( O& X; h4 o return% X/ n& o) B3 |0 K+ g q* \
#IfWinActive
6 g; S1 z; _( j2 u9 z+ G ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& a1 X8 ]% L2 K+ @* N3 N ; Note: expecting to be run when the active window is Explorer.
+ @- ], R* o; _% R& x ;
' g' l( M9 T$ H) p2 e6 s OpenCmdInCurrent()
! r1 V* {, T% Q. M1 x {
. B, M3 g: a/ B. u& V1 i; c ; This is required to get the full path of the file from the address bar+ C/ i- Y" g! H8 ]' q# T/ J4 U
WinGetText, full_path, A
2 d4 b- q6 M0 g# N ; Split on newline (`n)
; B& y- L. N9 J! P2 Y: q StringSplit, word_array, full_path, `n
4 v e& k. k1 N. N! ~ ; Take the first element from the array
+ } {" C' j7 _2 I! `. f* v full_path = %word_array1%" K+ [, G, G# `( Y
; strip to bare address
$ f+ f+ M; Y& B5 z1 W full_path := RegExReplace(full_path, “地址: “, “”)2 x6 D, ]; R/ [) M/ R5 L
; Just in case – remove all carriage returns (`r)
6 T- J+ Z6 }4 F& s1 z StringReplace, full_path, full_path, `r, , all7 P6 y* N; X$ ?6 b" A: ?; H
IfInString full_path, \
, T. |$ x* v5 E6 ]( G4 {% @ {
, {+ m* p" f8 t& E; U# ? Run, cmd /K cd /D “%full_path%”
7 K6 n& @7 x. K3 Z: a6 Z7 @ }0 A8 E0 s; w' @8 O8 |7 M3 e
else
: K2 i; o% y9 \/ q* Q! R {8 w1 E7 k0 U8 m
Run, cmd /K cd /D “C:\ ”
0 @7 m8 } L4 ~" c- y* p0 p }% _9 h6 s5 C/ W# r9 v! R0 z! V
}1 Q$ r6 a3 E) o3 q" Q5 s
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 f* y% Y) _: _# p9 N+ o9 w$ M 这段小代码肯能有两个你需要修改的地方0 ~ X9 d; c5 T. V$ p6 `; A
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 Q" \8 `7 _5 l: l4 a 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. n" u1 H8 j# F+ _2 U$ ^
|