此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& o9 \" G* r/ _' l9 b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; Z- X& J& e% E; O; L: S
方式一:' u8 F3 t1 @: \& m$ w9 G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 c h6 l+ C8 e& P# Q; Y e
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; W* b1 _% n1 U HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 r( D+ t6 n! o; ]8 R2 n$ g% q
方式二:1 \9 b7 B2 M0 ]/ o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& b' C$ ~7 F5 j" S5 G
SetTitleMatchMode RegEx! Q( n5 v5 A0 |9 u8 |! {
return+ \8 W2 l& I4 D1 O
; Stuff to do when Windows Explorer is open0 a) F8 z0 `, ?. u" f j
;
, r5 }4 y& r) X$ V) r8 V9 I" C5 @ #IfWinActive ahk_class ExploreWClass|CabinetWClass- X) t" t% Z% t- {2 P% Z
; open ‘cmd’ in the current directory
/ |& ^& ^* j1 ~7 C ;
8 v$ ?4 e$ x& V3 g #c::6 H: {* W) V9 c0 a/ ?1 a* y% h
OpenCmdInCurrent()* T) q9 n+ U8 i, n. |3 y9 f! s
return
; n7 d* s7 z8 l6 g8 Q #IfWinActive
* W1 _/ O7 a5 A/ i# J. B; N; T- Y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ q+ g" p7 N* |2 k$ b
; Note: expecting to be run when the active window is Explorer.2 H: z+ O$ e' @1 R' t
;, U! {8 H3 ^% ~2 l
OpenCmdInCurrent()
5 i1 Y5 s& J3 R( u {
: K9 m$ z- v0 r8 F ; This is required to get the full path of the file from the address bar N' o' b, I& N' M) _
WinGetText, full_path, A: c. P/ e2 O+ Z7 B! b* t
; Split on newline (`n)- [9 ^0 e/ U1 y& K5 K( N) R% u0 V
StringSplit, word_array, full_path, `n; M" r0 m$ m: T x6 @) ^
; Take the first element from the array+ |4 R( m: w; {4 g( X6 Q
full_path = %word_array1%& p6 c& A6 p" `* C
; strip to bare address7 L* ~5 U0 `( y! z! S
full_path := RegExReplace(full_path, “地址: “, “”)
: h5 }1 X6 e- |7 V% E8 M ; Just in case – remove all carriage returns (`r)
_3 Y5 [3 K! L8 b& g& O1 l/ v/ R StringReplace, full_path, full_path, `r, , all p: ?+ V/ @$ T, ?* D
IfInString full_path, \
, {# L: ^) \: ~3 c4 m {6 N4 P4 r+ {* F6 k$ l3 D; \( ]
Run, cmd /K cd /D “%full_path%”
2 i& Z% m( J0 z" D2 M' `, c1 @9 Q9 N }
6 w, o8 N' y7 Y+ [$ `6 T else
. a$ t- m0 z+ [( m {: c9 q$ f: W# H
Run, cmd /K cd /D “C:\ ”
w8 Q, T% L: q5 @ }
7 D* s# q& a4 B" t, U }& c8 x* I8 b% N
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* [ e+ f% H( {* Q; c3 P4 B 这段小代码肯能有两个你需要修改的地方: n5 m, Y6 T. c! ?+ T9 q9 N
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) J. l8 ?5 C- M7 S, p4 V+ R8 {, \( J! T 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ Z @8 \& m" d( v( x) _( h8 j' Q |