此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 i" k- n$ d D2 k$ } x4 E9 J+ }0 j
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 N# G! v" U9 G$ `
方式一:
8 y+ k2 d. T# i5 Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) b# _" ~2 q! b$ \9 s! a# r 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# b( `( J: c) G1 Z: M4 u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) ?0 [* U1 b" o$ ^
方式二:
/ F7 X1 Y. K' W+ P7 h9 _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ D s6 U+ C7 ^% o5 [& N; S SetTitleMatchMode RegEx
0 S) T( }4 `: J" I6 @ return
. F9 d+ i4 z+ d. \ e$ g" W4 c ; Stuff to do when Windows Explorer is open
" g, j o$ x$ `3 O: N2 ` ;$ p/ H% M/ k0 U0 j2 ?1 e
#IfWinActive ahk_class ExploreWClass|CabinetWClass
0 Y3 L; K% W3 b4 \* H ; open ‘cmd’ in the current directory
; ~( {2 S- h0 o% n ;! P6 a$ @- ^( ? p1 s3 K) S. ?
#c::
- v$ \. V4 I) r OpenCmdInCurrent()* J2 P; Q. q+ @. r! S4 Q
return$ Y, V" [4 x% d. F" E
#IfWinActive
1 ^ ^4 Y( b8 ?- B$ J3 k9 y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* U0 k3 Q$ E$ R1 g; j$ f6 ` ; Note: expecting to be run when the active window is Explorer.( \ \6 x. C# i. ~) c
;
3 \+ z( L! `/ \: V; t OpenCmdInCurrent()
. F! p" s. r1 H {/ j# |2 s8 H% ]7 `
; This is required to get the full path of the file from the address bar5 c3 a, l. n! }1 L
WinGetText, full_path, A
. N4 ?6 ]/ G- \ ; Split on newline (`n)
0 y9 [$ K8 W) u3 F1 Y* }. C" y9 d2 W StringSplit, word_array, full_path, `n
& J0 z5 Z/ k; K' b9 C# H$ z4 V ; Take the first element from the array
* o! B E- F" C6 d2 W; @ full_path = %word_array1%' u8 k$ d3 k `8 i! a0 k6 y
; strip to bare address) S/ a! B8 G! a4 H2 b1 k0 ?! P
full_path := RegExReplace(full_path, “地址: “, “”)
. P' |9 ^- a8 z. R& | ; Just in case – remove all carriage returns (`r)
2 P( s! V' Y7 ? C H StringReplace, full_path, full_path, `r, , all
1 U. K3 v. k. W+ N IfInString full_path, \
0 z/ O- t% n" l; `4 e* G2 E! s {
/ f5 _9 n2 M1 [ Z$ ~, Q1 P Run, cmd /K cd /D “%full_path%”
2 s1 U$ a1 l2 P }
# P. K, I: g8 m* Y8 S9 q3 W$ f0 H else
+ D# ?; z& V2 F" t* h {, T3 { ^( D' ^
Run, cmd /K cd /D “C:\ ”# k' E! e& y' Y
}
6 t- w: _* d$ u7 r8 \ }: l4 D, ?5 ^8 a0 N
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 I+ N2 Y' X' X 这段小代码肯能有两个你需要修改的地方
$ c& P* y$ \" F5 H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 q4 A0 P+ ^! Z. g
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; c* i. @* b% Q* m6 x$ _! Q |