此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ C" ^7 e/ a- v9 _3 A/ A4 Z( C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 z N# T0 s k& Y& a" ?
方式一:
# v0 M0 t# s% F3 }5 D 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' E- f3 Q( ^. e+ i
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
V7 Q3 p/ \3 q; O/ f" I; P% Z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 ~6 m: i6 i+ i 方式二:' K: }! [# O1 ?$ o$ J& v6 q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 _# n( @! P7 [ y SetTitleMatchMode RegEx
: Y! X+ A/ G0 |; H- l3 N# ~. O return" |" W3 S/ K6 H$ d
; Stuff to do when Windows Explorer is open
* U6 i0 d- L3 `6 O ;2 V& ?& l# J0 l0 a6 M6 f$ O6 h
#IfWinActive ahk_class ExploreWClass|CabinetWClass# [+ R/ }% c' _7 c
; open ‘cmd’ in the current directory
4 u) s: _5 c6 ^5 x. u ;+ O; K6 p; M" g( I1 ?& A8 d
#c::! Y) F! ^. n2 D+ u# `3 \& Y) s0 g
OpenCmdInCurrent()# ]3 D3 G9 W: ^! j. I5 K- R
return/ A$ w9 ?; O4 z5 r
#IfWinActive4 i! M V8 }" {9 u9 r" H3 v% W; v5 S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 D1 k% E0 n' Z7 N% Y ; Note: expecting to be run when the active window is Explorer., d3 P; m. v3 c1 g( Z
;5 Z4 z0 o' T4 K1 C/ W
OpenCmdInCurrent()( j) R$ z4 w; N
{7 q& Y4 ^) Y9 }& j% Y& M# H
; This is required to get the full path of the file from the address bar
9 w9 s( z, _3 G* y A! ` WinGetText, full_path, A
: k2 k w, r& |+ A# T5 a) D ; Split on newline (`n); G! D" m) U' j% j+ r
StringSplit, word_array, full_path, `n
r- ?" L& T+ y- h* I ; Take the first element from the array, ^9 y6 S2 l8 f* T
full_path = %word_array1%
& s9 L& }# m- w/ g g6 B ; strip to bare address
5 P; n: O) Z& K& p" c e- N( }0 h full_path := RegExReplace(full_path, “地址: “, “”), a6 X0 ^) D1 @: t& F* V {: b
; Just in case – remove all carriage returns (`r)
: x- ] D+ A; ^5 h* x StringReplace, full_path, full_path, `r, , all+ ]+ o9 B. K0 U. `3 e8 n2 h
IfInString full_path, \
, d# q) c* ^3 B& [" K" t {4 |+ z& |8 ~# H8 B8 O8 d
Run, cmd /K cd /D “%full_path%”8 C2 a6 t" r0 ^. L( k1 \3 u
}
* h( c" j" n+ U else; e9 Y8 [0 l/ O& D0 S1 R' u' L( w
{$ z k6 o: [7 ` _
Run, cmd /K cd /D “C:\ ”
( X9 {; O) _( B }
" g3 @' G/ J2 Y; {& `& [9 [ }: A3 L W2 l! q# Q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ B# k4 B9 ]* u: w$ j 这段小代码肯能有两个你需要修改的地方
6 A& I. A) k, O! V u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, Z! j( R" J3 W3 [; k% J* Q" e: U
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) _' [) g N' Y4 @% r |