此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, d6 G5 w0 [& }! L& I1 u4 z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 Q! \6 A" k5 r
方式一:
7 [2 ]5 B% p5 q9 ? 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# R. [! G0 F6 K$ s: V! u, {$ q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 d- C: N; q" n* q3 b8 Y, l HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ m5 M1 `3 g/ `! r/ R. f 方式二:
6 s$ h9 o2 |- [+ Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ C* E( @$ f8 F7 O5 m: f* l, v
SetTitleMatchMode RegEx
- o- Z4 V# F' \6 Z" C) J return0 i/ R" J8 n/ O& D2 G8 x8 h7 S. T
; Stuff to do when Windows Explorer is open
4 }9 @& \/ g7 d7 d ;' f2 v d2 u" ?. i. Z5 [0 h
#IfWinActive ahk_class ExploreWClass|CabinetWClass$ J8 O2 b* c% O5 I, o; {/ a' U9 E! x
; open ‘cmd’ in the current directory
, x* S+ ~* Q3 f" H$ V2 I ;5 H) D/ \' Y( Z8 m! U
#c::& _/ R! F1 _0 Z7 ^6 V
OpenCmdInCurrent()7 v" {* P0 r+ R) P: h$ F. b
return
9 Y4 p6 U8 {* y- I #IfWinActive
& E0 h1 R1 Z& w6 r8 _' l ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ u8 B2 B( B/ r$ ~2 V9 i- A* ?! E
; Note: expecting to be run when the active window is Explorer.; \2 F, f7 V* ^7 N3 ?( z
;/ x: K) x/ K9 ]5 k9 O
OpenCmdInCurrent()
( w- O, ?/ z; e# {. ? {/ \/ v- C/ [8 ~
; This is required to get the full path of the file from the address bar& y! Q8 U3 `/ J* @1 i" i. O, l
WinGetText, full_path, A6 D% i- T; v9 `: R) m2 z" b7 h5 w
; Split on newline (`n)
I& w: r7 W$ Y" u. E StringSplit, word_array, full_path, `n
# M' T$ U- o9 N9 h8 l9 B ; Take the first element from the array# E: f$ l( ]" f; D
full_path = %word_array1%$ u3 O$ M8 R; S) f' L' ^
; strip to bare address
( I2 s4 L9 Z4 K1 g full_path := RegExReplace(full_path, “地址: “, “”)
) P4 U) j0 S$ Z q4 U* b ; Just in case – remove all carriage returns (`r)
9 r$ A4 z* {! `/ H StringReplace, full_path, full_path, `r, , all: _/ }4 y; G3 }! s/ m c
IfInString full_path, \
; G$ `+ e" p4 k6 Z% g2 K {) @( N3 g2 Z& t& V1 U( j' D2 B5 U% i
Run, cmd /K cd /D “%full_path%”
/ B8 X( T! \9 ]' e9 e' |( Z" w }% K% ?& ^8 A0 u& F5 O5 W! ^+ \- e" n
else
7 p4 H" u& M7 G8 ^1 I2 R {& Z' R# f% @) A; c) L! s: P
Run, cmd /K cd /D “C:\ ”4 M8 V5 m/ _7 r
}1 V" J7 V2 T' H
}
" _! T) `3 o+ a3 K% p; Y* ] 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, ^7 _$ O. b3 M% _ p( \& J- E 这段小代码肯能有两个你需要修改的地方, f3 N* d7 }* p# D+ h w
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" T' p0 W# b/ I: u! v0 H; D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! ~; }0 d5 ^: v9 D9 R
|