此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 m+ T- E: ]* W2 I
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 f% P2 F$ A: H0 {% I3 e, X$ M
方式一:
, y5 X1 H+ D) j 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 }. B8 T, x* M/ `, I% F
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* u/ d/ k0 B7 c( A) z3 ~2 y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ A+ c3 F! W0 r& s: A3 d- Q
方式二:; z% o* M4 _# D" B/ u7 I/ k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- I6 f4 ~' n$ J& ] SetTitleMatchMode RegEx
2 u' G% c$ F+ U# q return
8 P4 e6 h& ]( f& t ; Stuff to do when Windows Explorer is open6 E' z3 \6 z1 \0 B3 k3 c+ V
;
+ \& Y0 B3 e' _7 v #IfWinActive ahk_class ExploreWClass|CabinetWClass
% W( c- Z" Q5 ]% N6 { ; open ‘cmd’ in the current directory, Y8 a1 N% l( D* m: e; P1 |. T
;
; a5 r" x0 z3 L" G- h5 e/ r* Y #c::0 ~; b7 m/ f2 ` Z
OpenCmdInCurrent()
1 z# j7 ~7 G6 T3 O9 B. ^ return. O: d8 _; g; ?0 N. _0 q+ h8 Y
#IfWinActive
% E5 F A& f' v5 D3 @8 ^ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 U2 C# M6 R5 b- y& X! ^
; Note: expecting to be run when the active window is Explorer.! @0 p! s4 c9 b1 u4 L, Y5 E' ~2 }
;
# E# ]4 g5 ?9 e; s7 Y( B( ? OpenCmdInCurrent()* p0 p! T* p+ o. C/ T9 p5 m
{- m1 v/ D1 s1 D% V" f# |
; This is required to get the full path of the file from the address bar& R4 _0 C8 D# l+ I8 I4 g
WinGetText, full_path, A) F t( H4 u6 W; o
; Split on newline (`n)4 @: C( _/ e) d4 d
StringSplit, word_array, full_path, `n
5 ^' Q) Z! [5 ~; L ; Take the first element from the array
$ x% x6 n7 R2 I5 Y/ g+ i6 L full_path = %word_array1%
/ s# h0 L; Z% _) P5 ] ; strip to bare address* v% I& [* K7 b: {" Q3 \
full_path := RegExReplace(full_path, “地址: “, “”)
/ n z! b/ h- |, `9 C ; Just in case – remove all carriage returns (`r). |% c1 h r; K5 j6 z/ q4 k8 S
StringReplace, full_path, full_path, `r, , all
; L) g4 T' t/ b; s& i IfInString full_path, \
# I# N6 n* |9 |1 S* y3 g* `3 Q {. \. ~. L( x* v' I* T1 v e
Run, cmd /K cd /D “%full_path%”( o. ?' I4 [/ {5 K# @
}! m. A+ ^+ a6 n, a7 L1 Y
else# K- g4 l0 [1 n
{
& [# O2 M; A: D) N# j Run, cmd /K cd /D “C:\ ”3 ~& T# f- S* b: g- e% j
}
3 R* D1 H+ d. X; J; Q }
?* z& l4 V! C! q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ z/ c- x2 a/ p. \) }% u 这段小代码肯能有两个你需要修改的地方7 b* S# B1 S; y) \
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: k" f) t7 W5 R6 V) S 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 ?' T8 y, f2 x |