此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% E, w* b0 i, u" O! j
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 [3 Y1 N7 X$ V; @$ ?' ^/ ~
方式一: w, X+ f. f! ^
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- Z! E* ]: Q. v0 {7 r3 @# N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 v. l% [$ f" A! k HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; z: V# S7 }% p! U' ?1 [7 l8 A- i
方式二:
* I, F; J+ }: d8 ]6 W3 N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 S& Q1 K! ?6 i3 ?1 _ SetTitleMatchMode RegEx% U: s( p9 e1 p: R3 E
return# e, r: ~* Z) f5 D. i
; Stuff to do when Windows Explorer is open
% O4 t! f G8 O8 H d: X# l ;
% J- A$ T4 S' z0 s% Z #IfWinActive ahk_class ExploreWClass|CabinetWClass! _' X. ]) U6 X# b) K, [& i2 N0 _
; open ‘cmd’ in the current directory
4 G% W Z+ W- n, M2 d# y1 p- h ;2 K# I0 h# X3 m1 F. V
#c::( _/ J9 C; Z( }: x0 j2 b( e; {6 U* C
OpenCmdInCurrent()* V* e0 w! m3 A# G0 g/ n3 W; G) {
return& h" V; k; `8 U2 x$ [( `
#IfWinActive
% D. x- f: R& F& ]( O ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." R+ f' O; o3 s I8 m) B/ A+ v
; Note: expecting to be run when the active window is Explorer.7 y' x/ P" v! G( C- ?7 h6 f
;
6 z l" U# V7 O6 o- K/ z& b6 ` OpenCmdInCurrent(), f( l0 O6 V E9 j
{! U6 C9 Z6 W- l4 t4 t7 ?
; This is required to get the full path of the file from the address bar& t- i4 K( m. u; ~ b
WinGetText, full_path, A
. u9 u" I3 j: u1 z1 j$ d, q- Y+ Y ; Split on newline (`n)9 o1 z$ q/ R* Z5 {
StringSplit, word_array, full_path, `n. O1 s3 C% W! i- z4 @) d% q
; Take the first element from the array
$ @6 ?7 \3 J5 O) p; b1 f full_path = %word_array1%
I# p# |* Y2 U8 t- P3 |" v# U ; strip to bare address! @' P% `4 p6 e0 F4 h& L8 U5 W
full_path := RegExReplace(full_path, “地址: “, “”)& P3 H7 N" g. y0 g# Q# h
; Just in case – remove all carriage returns (`r): Z% K. v( I3 Z" u
StringReplace, full_path, full_path, `r, , all2 W* @% f, K- i6 O
IfInString full_path, \- ~& ?+ n n) E
{% o. ?) i8 t% Q( v0 x5 P
Run, cmd /K cd /D “%full_path%”; F7 f% P( n( d5 {. a
}& K- i5 B: v: f4 g
else& o8 {! S: Q( J/ e3 g3 T
{7 w+ Q4 N; h0 U) v/ t6 F" l
Run, cmd /K cd /D “C:\ ”
2 ~. n2 z' a! d/ _% E& N3 d }0 O% F5 r! b, \3 Y! d, A) b
}" a$ O* z/ ^ Q4 H+ w
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 v0 H% ~0 _3 _+ X
这段小代码肯能有两个你需要修改的地方 e. g/ Y+ E, a+ S; V3 @: k
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ Z8 L$ V# u0 x& l8 }3 }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ I) j9 o/ x. a" \1 H |