此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 K$ K2 u+ N3 E8 E$ G 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 T# D8 M6 u) t$ W5 K! M 方式一:
1 b1 B* M" {; r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! w; E+ \# D7 F
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( ~/ y, `( d2 p0 M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) g, t& I8 Y' d+ L& Z& e8 S) c0 V
方式二:" A- B. L/ G. h0 u k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 D, a5 S1 `/ }6 |; s/ x. Q
SetTitleMatchMode RegEx
6 i/ l/ b( N7 K, k return
! p# K X v F4 I ; Stuff to do when Windows Explorer is open
, `. m; a6 K3 i7 [3 t" J% l ;
4 h; j3 Z8 @. g #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 Y& e* n* A6 ~* _, r% t' p ; open ‘cmd’ in the current directory
6 Q5 }5 ]4 S) I: s3 p ;, j) m& L( L$ \3 q; m+ t7 ~
#c::
8 t7 P; p5 t9 k. |! l/ y2 W OpenCmdInCurrent()2 c' w5 z, j; q5 \
return
+ T; x: y! h) Y0 d v# o #IfWinActive
+ i" Y7 }4 I8 E ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 J9 f1 W+ ~# X1 C% W5 B ; Note: expecting to be run when the active window is Explorer. C6 R3 G8 w* g8 j# P2 ~
;
: [& T- s# F2 s$ O) }' F OpenCmdInCurrent(): ~4 v$ D- w7 e3 S: E% Z0 T
{
# G3 ^1 E; G3 u5 ^: k/ w ; This is required to get the full path of the file from the address bar' Z0 t3 W( n1 L; Y6 |1 \5 o0 _
WinGetText, full_path, A q0 q6 W' A1 Y
; Split on newline (`n)
5 f, T! Y& r& b5 ~. W+ n StringSplit, word_array, full_path, `n
; T1 D/ r; I* }9 ^ ; Take the first element from the array) F$ m& V& W9 B
full_path = %word_array1%
; }) @$ P1 \8 V; S4 ]" S ; strip to bare address3 h! o/ D9 n( G: s$ r& Q; l
full_path := RegExReplace(full_path, “地址: “, “”)
1 @7 G! D/ D& X7 C ; Just in case – remove all carriage returns (`r)- c4 |3 h4 X( k+ w6 E
StringReplace, full_path, full_path, `r, , all' v) t& o2 i" }7 m: N
IfInString full_path, \% { p! ]. y8 W9 \; g: r. u) V
{
7 M# j; i6 k% k0 } Run, cmd /K cd /D “%full_path%”
& V3 e/ o3 @( ?3 Q- `& u3 @6 Q5 H }
' \& d* V) Z' O3 _: s* E else
; G1 l6 e: P4 p3 ?6 \. ?! K2 s {
. ~' s$ W+ m; ]6 W$ O9 N Run, cmd /K cd /D “C:\ ”+ M* E2 x8 ]; L6 C8 e- d
}
4 g8 j# \/ {1 L }
, S) c: }' T1 v, D4 ?; b% b1 s 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( ?! q9 E1 Y* @8 p' X( b* s
这段小代码肯能有两个你需要修改的地方% D2 K8 O8 Q* e8 b/ H% A R+ ]5 p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 Y, u4 P1 D8 i* [( J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" v: R# M( e; I
|