此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 @4 b" e& }; d: h
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 H: Z* {6 c6 w v d# @: ]6 P
方式一:. K R& d4 W8 _; m8 S% K- O
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- n2 Z9 x Z- L) V& x, v0 O1 R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 a3 r0 P$ Z/ r% Z& I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* u# ~3 M2 Y6 w$ O, @- y
方式二:% e2 H6 W: C: c# y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* m0 l; _: u' k" B SetTitleMatchMode RegEx/ Z6 E; j2 g2 R+ u$ Q! X
return5 @/ ~# m) [: y% | X4 m9 L6 n
; Stuff to do when Windows Explorer is open
. d1 S; d# h; w3 m) m3 s; d/ G r ;
+ u8 P |6 k* X1 n2 {; t% b" s, j #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 `9 `' x1 g, V ; open ‘cmd’ in the current directory3 d5 w- J, P% |
;% R; S+ L9 t! _* F* }: G
#c::3 ?2 y/ M0 e t* ?; E; x/ L+ a* y
OpenCmdInCurrent()# }' e0 C" T5 m. m Y
return9 i. \/ W9 A6 S
#IfWinActive' C5 I6 F) M6 t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! F( h, R, \6 v2 n ; Note: expecting to be run when the active window is Explorer.' S9 \9 q9 L! }
;" D0 ~3 q2 d& I5 W
OpenCmdInCurrent()
5 b7 `. y9 c% q- o {
% g% H+ c9 W5 _/ L ; This is required to get the full path of the file from the address bar6 J* g( D' E' G% u* f* B7 O! R
WinGetText, full_path, A
# _. r" w; J$ M% w% w ; Split on newline (`n)
) k* Q* C) i. N, ]7 ~ StringSplit, word_array, full_path, `n
. Q; ?) j E$ V+ }6 d, ~, | ; Take the first element from the array
' n3 X, ]% x2 q0 ^3 x+ ?- u( W9 i& ^ full_path = %word_array1%
c, W2 P9 I- B& { ; strip to bare address# U3 a9 k6 Z* o+ I$ |% B
full_path := RegExReplace(full_path, “地址: “, “”)7 i9 L% v) e1 B; d
; Just in case – remove all carriage returns (`r)2 r$ Q/ Q& K1 D, x& H7 r) V+ F! {
StringReplace, full_path, full_path, `r, , all
. j4 o, A0 ]9 i& ]: Q IfInString full_path, \1 ]+ b7 \) U; U1 y7 v
{. N6 H3 {4 W* E1 G- X
Run, cmd /K cd /D “%full_path%”
' h$ \* D; v7 b, E! e }7 z5 a2 e ~/ ~9 r4 F
else' E" ], ~- @4 I
{+ M3 k7 @; t# @0 C+ A' i, d
Run, cmd /K cd /D “C:\ ”6 A8 c% V J# W- s: J
}
) I3 o: }8 f, U8 b3 {8 p+ F. z }
, b0 i1 M _: T( W( \+ [# E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" F/ M( W4 @, b4 i, r/ a& [, ?' b. m
这段小代码肯能有两个你需要修改的地方+ `$ c9 { C/ W! [2 A$ w' H ^$ b
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( Y! u- r! u* n% Y) t6 D
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) S/ y$ x$ Z8 H$ @* T, M |