此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% y' ]. a* J: x 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, P L& l/ N I2 |
方式一:5 M7 H& ~6 H6 m+ ?. l8 q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 M; l+ X, ?$ n% w! j2 m2 Q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 J. q; _ e L, ~ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 |% b6 n$ ^8 Z) l6 _/ w 方式二:8 n* D( j5 _; p( K# Z) l. N. k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: k' h7 m" |5 f4 \! o) j
SetTitleMatchMode RegEx7 R) G6 @9 w$ [( z
return
4 z0 d: U9 S+ k* j& f ; Stuff to do when Windows Explorer is open7 [' ]* |+ S: Q, U/ k
;
; O" @6 G" |" W2 w #IfWinActive ahk_class ExploreWClass|CabinetWClass
- I8 [2 G9 l4 I7 m) ? ; open ‘cmd’ in the current directory
l% y5 w) |6 v, x: y; m. { ;
: O r) Z4 E3 u, t/ V5 l8 w! W5 K/ V #c::
U; O- N. B w# t% Q OpenCmdInCurrent()
; n5 e7 h: F2 \ k return% F) V% p4 B9 P4 u- W
#IfWinActive
; `' u4 e# @1 P: C ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; }' W! a5 Z! K* N- K* w" t, l ; Note: expecting to be run when the active window is Explorer.) Y6 V8 w1 f/ B$ {
;! ~ C8 {$ u- d! c
OpenCmdInCurrent()
/ s9 c& r+ N2 C* U6 n* l4 G2 K {; d. N+ n( Y6 }; ^# t# A% t4 G
; This is required to get the full path of the file from the address bar: o% z: W) B8 w( O6 x9 K; E
WinGetText, full_path, A
% L$ f! f8 k, t" f& A. w) j ; Split on newline (`n)
) U4 j! _. X% {+ u9 c3 | StringSplit, word_array, full_path, `n d& t2 h* _' {5 Z0 |! |% D
; Take the first element from the array4 E. D5 _( j' n2 h# _
full_path = %word_array1%) N+ `0 z( x% _5 B% ~
; strip to bare address2 \# N6 r4 [3 I
full_path := RegExReplace(full_path, “地址: “, “”). m- C4 g; n: g+ p
; Just in case – remove all carriage returns (`r)
( F! ^: I) S U0 d StringReplace, full_path, full_path, `r, , all
! g/ S5 y9 R9 U, h" X IfInString full_path, \
& m) l$ H2 \ A- P {: g( h, b' \+ `" d! u$ r. v. ?
Run, cmd /K cd /D “%full_path%”3 X5 W( C1 M8 b. G/ y7 k4 h
}
3 M& B2 c$ u. A else
* z9 [9 ]" C ^- c$ u, K0 I {
/ b! W7 y/ ^/ u/ \% e Run, cmd /K cd /D “C:\ ”
6 ~9 { e0 w2 D& j$ o0 k7 Y6 k } ~6 u+ z# R7 B
}
' L- N, F# u4 B) C3 G" P# U" B 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% x! G+ m* H& j! j
这段小代码肯能有两个你需要修改的地方+ H& F" G4 y3 M9 `3 H
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' Q5 a# h% l4 u; { p0 C$ w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) H8 b7 w# f0 y+ w7 i2 W/ h9 D |