此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ f# w* ?/ A# r5 q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 z) ~6 x1 d# J' G+ F2 i 方式一:: m, k' K! u7 V, S
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* R2 H) n1 z" r: T* P; T
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ v& ^* Y/ d% L9 W! A+ G HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 U9 w q0 | f2 R4 ~- y7 B" a
方式二:7 s- X x* C" r+ j
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: e# x0 c& i# i! M Z
SetTitleMatchMode RegEx/ x( w3 C: s" K5 w+ a7 g# b7 p
return8 H2 U; D6 {9 y& K4 \
; Stuff to do when Windows Explorer is open
5 b+ J+ J4 }3 c/ k1 C* z5 _: x% J ;3 f/ `. n/ G0 a% c6 Q( Z- a
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 H+ ^2 k5 Z; k g1 u8 q ; open ‘cmd’ in the current directory
+ H6 K" t* W4 G% Y3 F1 R5 \, n h ;. A. u( P" b( E9 k1 {# s* k6 e2 C
#c::8 T* w0 o- U+ V
OpenCmdInCurrent(). U, r' }( p# G: P
return
X% f( L: [) ^0 f/ h! `8 J #IfWinActive
8 G& E% H: T) M2 z+ | ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 g! K7 M: h1 E- ~ k ; Note: expecting to be run when the active window is Explorer.
8 M5 g/ |! u0 v5 h5 T ;
) G; O- b+ j; s6 u+ A4 z. G6 _ OpenCmdInCurrent()
/ p8 |% `' e$ m* H9 A5 T/ P& c {0 x0 T j4 o3 ]- r/ n: d& Q( l, G# H3 Y
; This is required to get the full path of the file from the address bar
$ m6 ] b% h$ T& Z' U& t6 P- R WinGetText, full_path, A
/ k3 h" e- ^ T7 _- K8 x' Y ; Split on newline (`n)4 p2 n- l- v1 ^: W; Y7 p+ x" S
StringSplit, word_array, full_path, `n
, G9 h6 f0 K2 l ; Take the first element from the array9 M, i' {; S* V' {* I/ h
full_path = %word_array1%
$ v- c) T' `& c5 ^ ; strip to bare address* n# K! _! |, s/ e I8 \+ I
full_path := RegExReplace(full_path, “地址: “, “”); k U- P E7 Y6 c; m& P
; Just in case – remove all carriage returns (`r)
& [2 P* O$ U/ ^6 B( H StringReplace, full_path, full_path, `r, , all6 E- Z* p% C0 y4 Z) d6 S% x* C
IfInString full_path, \% H7 o; h2 _. y9 d9 L+ i
{6 f! s B( g4 z0 h* e$ C
Run, cmd /K cd /D “%full_path%”3 X5 X1 U9 T0 q0 h, ^/ Z8 u
}
. Z1 _' D4 \8 \5 I$ ]* G6 Q else
3 W) ~, B5 b. `1 S. G! Q0 d {
. ] y# f, o4 _4 D1 W6 n1 K9 A Run, cmd /K cd /D “C:\ ”) `) s7 ^" f& J4 i0 E/ b
}: Z' _( k% K2 r6 j: Q! m2 g+ Q0 c
}3 x/ g5 c0 F g C& E
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) B" c4 A2 R- [: _ 这段小代码肯能有两个你需要修改的地方* ^; B( ?8 g9 B7 I0 |+ O
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" }2 r7 l: z" i( `& B3 r( U! V
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) K5 G5 P( `2 U' }+ _; b
|