此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 q- e$ H. @) k; f3 `) \ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 m8 C9 K5 x, z 方式一:( r* A) s* J) U6 _- Q7 R
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. {% @. l. d; E/ R: }5 P6 Y. s( a2 D 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! l5 H* n8 [4 N; e! J/ n
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, m# Q$ D$ E1 p4 v9 r F& b* u 方式二:9 U$ A1 B1 D) I8 Y8 n k, `6 L
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 F! M, P$ e1 j5 l* a. l; k SetTitleMatchMode RegEx" e0 S' r' w' I7 ^# n
return% Z# X- w- `) F* p8 e
; Stuff to do when Windows Explorer is open
- w+ X/ m$ Q& U5 s ;, t1 Z. \) `) G. ], K
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 F* L% Q6 l4 ` ; open ‘cmd’ in the current directory! Q4 I4 n4 S5 Q+ }# q( c) i
;
5 G" g; L5 d9 [: Z #c::
' z6 F3 ]$ v4 Q/ x, h OpenCmdInCurrent()6 n3 t& w: O, j2 u
return& k) |( {$ \6 K/ G9 `7 z* T: c
#IfWinActive" v3 i: G! F6 m$ s8 ~ c
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 g; r5 C9 S- y3 H3 {+ E' d- U
; Note: expecting to be run when the active window is Explorer.
1 b) ?6 \/ e8 @' ]0 h ;: s2 v' x2 P2 e3 ?0 I s
OpenCmdInCurrent()9 _/ h0 t. n, f
{
3 p T5 v, k% d! a2 o* A4 P8 R3 w ; This is required to get the full path of the file from the address bar' q# G2 S1 o- U& F
WinGetText, full_path, A: n, |) ?9 D0 r
; Split on newline (`n)9 R# [$ [7 F" E8 m7 V# I2 K0 x
StringSplit, word_array, full_path, `n
% j& C( f) m$ i. j- O6 O% t( C ; Take the first element from the array4 @! v/ I E2 Y; I( |' D
full_path = %word_array1%+ O" X& E) @" B: f( s5 F- {
; strip to bare address' x: o1 s6 \+ A- t" V7 c
full_path := RegExReplace(full_path, “地址: “, “”)2 I% G2 g) O9 }1 O5 Q" w$ Y
; Just in case – remove all carriage returns (`r) I7 n+ g d7 D9 [' a
StringReplace, full_path, full_path, `r, , all
r8 X& q9 X1 x: X( | IfInString full_path, \
( N3 y: m/ w( r u& p4 w7 M {! ^) P' S$ h9 ^: I3 _ ]
Run, cmd /K cd /D “%full_path%”/ ?: U/ r# \9 h& x6 F
}
d& i; u3 F9 M: p2 P else& Y/ Z# Y5 K, Z2 o& S
{5 i# I P+ `: r' d/ @* ~8 ^/ f# k0 H; G
Run, cmd /K cd /D “C:\ ”! h" F. ?2 W$ e* N
}3 ^4 M3 P% W: o) v6 M
}. G. c) [. o0 J1 ?
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 r: `0 I/ ~2 B+ q3 _% _; ]3 i l* l8 X
这段小代码肯能有两个你需要修改的地方
; M6 } N5 N T 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 R" u$ E6 Q5 o: I% A 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( V5 Z) M0 \1 h0 w) {7 S |