此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* E/ n- U5 b4 s1 P* b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! I5 T9 Y2 s' R5 w3 {$ V) f3 a
方式一:
* a* I3 z: M( p8 ?+ N, E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% m5 k7 }3 \ r! o 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 f6 e; n8 K" q7 V( i: I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ ^/ s6 y6 z1 O3 E6 v$ N
方式二:/ p4 C" |6 v' t
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 w0 w: f8 V0 w- G- _, B. V
SetTitleMatchMode RegEx# { v9 v* F& i. N* O/ x' }
return
0 L: Y* s8 e1 ^! @" f" K8 i ; Stuff to do when Windows Explorer is open
$ ~/ }) m0 Y( y* e' J0 e; r* S ;
7 V# S+ V$ ^1 D% C7 P( ] #IfWinActive ahk_class ExploreWClass|CabinetWClass
( Q9 P8 s4 N5 J& m* H ; open ‘cmd’ in the current directory6 i- U+ d: i9 I4 n' s/ S
;
8 ]0 R ~9 e2 J. \/ l0 L #c::1 Q6 D0 @& I- }0 u+ K& q5 z0 Q8 U
OpenCmdInCurrent()
1 G3 x" B- K' `9 J return2 ^3 D1 a! R @6 y, s1 g* {
#IfWinActive6 X- i/ q( t) G4 q, H
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- j" f* n3 ^; j
; Note: expecting to be run when the active window is Explorer.2 e4 \! b* Q# W
; e# |9 [& v5 u. |
OpenCmdInCurrent()# E. y8 |' E. _0 y- b% i3 b' s
{4 L$ p5 v$ o- D5 G
; This is required to get the full path of the file from the address bar
* P; M( S( z( x5 Z( Y* g2 D WinGetText, full_path, A( ~, p7 c6 ]; N2 [: s0 U% \) ]& J: B
; Split on newline (`n): h4 a5 Q. V1 ?
StringSplit, word_array, full_path, `n) Y/ C! e0 s( ~/ G% S
; Take the first element from the array& U: k2 @( l: o
full_path = %word_array1%: p0 Y& ]6 A7 t- `2 { G' X
; strip to bare address, n; ^6 h' N( q- N; ` \8 a
full_path := RegExReplace(full_path, “地址: “, “”)
( U5 O) G! C$ x3 y7 ` ; Just in case – remove all carriage returns (`r)8 d" S/ o7 q# r' f- @7 }9 j9 b+ z
StringReplace, full_path, full_path, `r, , all
* J% ?/ q; l1 f- S IfInString full_path, \6 r4 `+ @6 s, l- ]6 @; b* m6 k
{
% v3 i' i1 V$ a2 Q# y9 ? Run, cmd /K cd /D “%full_path%”
$ H1 J- f# G! T- i" D }; v3 A2 z1 v/ {: v- n
else- B+ j( j; S1 K; X$ \
{, v5 S. U6 m% t* \+ L5 t- c1 o$ [
Run, cmd /K cd /D “C:\ ”9 l- ]8 v8 o, P
}2 b' ^. Q- J8 u, G, @1 Z/ |# p
}( i1 i' s7 r9 a$ M3 u
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- a9 Q. J0 u- f) z; D
这段小代码肯能有两个你需要修改的地方- ?. I0 z/ C2 ~
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& n0 a% T7 l* m
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) C, W2 a; M5 H& y! S& }1 f6 t7 N# ` |