此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; V0 G; g! X/ K8 d# s. Y' L. m: `
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
D, }8 j5 ]% x6 ~4 x; j 方式一:
% C9 k3 v4 M. ]8 o/ O4 u E/ E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& i+ n. l0 I$ x& S
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) J% P0 g$ |4 O
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( d, }1 y5 W; r+ m: o* ~! l
方式二:
2 M# O0 `( l) \3 Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* l D5 f" v" | SetTitleMatchMode RegEx' t" U3 m6 j1 R; c9 K
return
2 n2 N* M% E0 Q) D( `0 d ; Stuff to do when Windows Explorer is open; s+ S8 A3 f. I) v8 R( b* M. R
;6 ], ^# D* J1 z$ n& X% u
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' T% h2 h0 n7 _( g. G2 i* G' N ; open ‘cmd’ in the current directory4 s; H! D# O5 n, F% O L/ G, a
;
- V6 C- k# h& z0 @7 P/ f #c::. A7 U# i& s& y1 ]. J% f9 N! q
OpenCmdInCurrent()3 `4 E3 N- Y/ G7 h- @# P
return# \4 `* l8 h8 k% m/ U: ^
#IfWinActive0 s; y. ^5 n7 T' x, s8 z; T- E: j
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ \6 M8 v' C/ V" O
; Note: expecting to be run when the active window is Explorer.
( a l& ?9 m- ^4 ~% z0 g: k ;* u! S4 e, ~2 W7 H. x1 A- z* M5 u
OpenCmdInCurrent()! K$ N2 H1 v2 P0 U0 e9 D
{+ d* b) X5 i4 l r4 R
; This is required to get the full path of the file from the address bar- ?" e# V0 v) o) ^9 h1 D6 q
WinGetText, full_path, A
4 Q: T( R+ p* {5 y- j! _ ; Split on newline (`n)
) e; l3 h% \1 V, [+ h StringSplit, word_array, full_path, `n
: q* `3 Y# w! `* r" r ; Take the first element from the array
# U6 w! _: i* I; Y full_path = %word_array1%
% q0 ^, i. N, f J& @ ; strip to bare address- H8 }8 s5 P* N% W! h; Q, W. B
full_path := RegExReplace(full_path, “地址: “, “”)
% R- ?# v5 o: h7 v) P; | ; Just in case – remove all carriage returns (`r)
2 _8 V# ~. A2 _$ u% ~ StringReplace, full_path, full_path, `r, , all
0 b7 z; D4 [$ h7 e IfInString full_path, \
' \7 w# u/ B) m* I3 R {
; S8 q u. z( r Run, cmd /K cd /D “%full_path%”* L) C5 p0 l2 j- i/ B* s+ K3 c# d0 q
}
: _! Z# N5 x% E8 n) Q else
# X0 z; f/ d& C3 [( A {
$ N P3 E. l9 W4 k! n! X, ^: {2 h Run, cmd /K cd /D “C:\ ”2 w# e/ }" v& J0 Q" L& F9 x9 d
}, G; J7 L$ y: e8 T( U A
}
: H( K0 s$ I8 p; b0 N# E) x ^ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ n9 i0 }; |# B6 y/ q+ C% A 这段小代码肯能有两个你需要修改的地方
4 r2 o; Z, d- b9 e 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 M: `2 S' D% w( Z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, j8 j" P) e* I9 I
|