此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' `# N9 [0 ~4 i6 A( O* Q2 M 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 V& |' i k5 r; L3 o" |
方式一: Y Y+ D3 r Z$ h1 J1 l8 L
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- q+ K: L# a! s: x
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" I0 T' y6 A; n7 E9 n' z' ?( x
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" ~0 P! A' o1 z, m8 I
方式二:% \' F$ P6 b; x
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 c( \/ h7 y8 w SetTitleMatchMode RegEx# @2 @" h U6 J# L |' A6 m* z, A+ k
return
; o: X* W- l' x. q ; Stuff to do when Windows Explorer is open
: d% ]! L0 p( V. N; Y# H ;3 f0 s! M3 S* d; g; U7 I% P; Z
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 j6 h% }" P' s) t9 _% _ ; open ‘cmd’ in the current directory, K0 z+ i4 k+ D" c
;" P' m. n, T$ g# M) b- {* |# I
#c::) u' D/ B. ~2 r5 Z S
OpenCmdInCurrent()
' L2 Q* z4 k! G8 b; l9 V2 j return
$ [% g$ C9 a/ [1 G6 A3 e; G #IfWinActive
" c5 |2 q. G: W b. i5 M9 ^ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! M8 f! }. P5 E6 K ; Note: expecting to be run when the active window is Explorer.
6 ~- i; A; r1 P$ f ;
4 v: ?1 D3 U" |3 Z8 K OpenCmdInCurrent()
/ @" ?& m9 W' v, a9 B {8 ]" y' g: h7 w N* P* b
; This is required to get the full path of the file from the address bar
) ~5 |+ }4 R' h* c WinGetText, full_path, A
) d6 c: f9 j' r: W ; Split on newline (`n)
* g- h- |& A7 \+ ? StringSplit, word_array, full_path, `n
7 K: i9 C7 F. l3 { ; Take the first element from the array
1 R$ m6 l& e" E- B y, F/ w' M full_path = %word_array1%9 K* M3 T% w" j/ X ^
; strip to bare address3 t$ e! b$ R& Z; e& m! B
full_path := RegExReplace(full_path, “地址: “, “”)6 b: z# P- X0 W$ r* e8 x) K/ z6 d
; Just in case – remove all carriage returns (`r)
8 G7 l# h4 { ~3 v8 k, }/ e6 X StringReplace, full_path, full_path, `r, , all
2 z) M7 e* f# M8 Y! E7 M( X IfInString full_path, \: K- c- m# Q- G+ H* f* S
{* W8 Y5 b2 }" y
Run, cmd /K cd /D “%full_path%”
$ v1 B: O) b0 E$ a } A# v4 I" t2 L3 K+ u5 R
else
3 B( G o' k! o: \* v( h {
2 t; z" e- ~8 E9 z. d( r% H4 O Run, cmd /K cd /D “C:\ ”
# h0 n+ ^2 i( M2 G2 H" W }
* H6 Z, u( X) w; a9 g1 r }
3 ^/ A* I/ g4 ~8 D 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 P; S: O/ y/ ] B% f$ q
这段小代码肯能有两个你需要修改的地方# M% G3 z0 t- F8 L; u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" y: Q2 M; z- R# u 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) L6 R- ^% U- S: F# i5 t) j |