此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& O* G3 {, G- Z B( v, [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
% `2 ]) @* T; [5 i* r5 @ 方式一:2 `, I# r# W% Z$ k
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ \* E' t4 H6 ?6 F- U
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' B% q7 H6 _5 Q7 s
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% n# x W# \" H) `( L 方式二:
( |/ Q2 q; [! ]# k/ V6 N2 G 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ v4 n ]9 H; n8 ~- s# t9 y4 F SetTitleMatchMode RegEx
, W" }$ T' C, ?7 U" o return- e: F* K$ q" T0 m# p, y. p0 ]
; Stuff to do when Windows Explorer is open( h# ]3 f' \6 g9 q/ i$ L
;: i9 I! ?2 m. d
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 c ~, \. ]) l/ s0 v0 D
; open ‘cmd’ in the current directory
0 @0 l" T4 B: x/ p ;7 Z8 h+ N: z0 K0 O5 O
#c::8 f; o# w# m W
OpenCmdInCurrent()
: R" s# G/ ~ l; Y3 L return5 U/ d) i( y' b
#IfWinActive
% o! I7 W3 i1 H4 C2 M& j7 L; j ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, Z4 A3 H+ G; ^& | ; Note: expecting to be run when the active window is Explorer.
m% L5 D8 G) @5 P9 O" D* G! A; } ;5 U- M8 c- p' \7 i4 i& c
OpenCmdInCurrent()
9 {- @* e' b. _, k/ A7 M8 V {
- ]2 M+ `) Y4 P k" p, ]. P. Q ; This is required to get the full path of the file from the address bar
" q6 R, S6 }5 @ WinGetText, full_path, A
- _ \% x6 l) T ; Split on newline (`n)
# ^1 P8 B, O4 [: _ StringSplit, word_array, full_path, `n* z2 }" L6 M1 q G% @2 j# P f
; Take the first element from the array8 X, f! g8 e% G0 R2 S
full_path = %word_array1%
7 Y' ? b' s& {; @$ |, l0 T ; strip to bare address
, s& I" L4 U/ v2 ]# M9 _0 j full_path := RegExReplace(full_path, “地址: “, “”)
7 J9 a( ~; Z. C ; Just in case – remove all carriage returns (`r)
& Q3 J0 e7 I& T! c1 \ StringReplace, full_path, full_path, `r, , all- P1 V. q3 X! B T P
IfInString full_path, \+ m( H' h% @) q( Q+ ^$ ^8 M
{
8 s0 B! K8 W3 O Run, cmd /K cd /D “%full_path%” F$ E7 K0 V3 Y# c2 J1 Y6 R8 Y+ \
}
5 k; g; A% n0 g" }" M' F5 a else
: u% s% ?* N* Q0 e+ h }) n2 D/ W {8 M7 l7 r5 ^0 X+ v+ f5 j7 ^
Run, cmd /K cd /D “C:\ ”
2 S/ n3 ~( p/ c) v }
! y9 h: e& Z) v, n" e4 w; R }4 s, [' {+ t- U/ \; S
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; L2 A8 V# r L3 z7 I$ F! O- b 这段小代码肯能有两个你需要修改的地方 J) o1 v8 T/ T1 e
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 |5 [' V( ~# _8 ^0 Q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 ~! K5 m0 v. e6 M( U2 J/ ^
|