此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' r. I( U7 ~" `
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. o) ]$ f2 ~8 ^, ? t+ | 方式一:
, D7 x1 A, A' L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' N( k* {2 c) C# D
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: N0 q( I+ o0 C. W, O( D: J% u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 x8 v, s7 k( H" E' P" F4 F 方式二:, s+ Q6 b) l& N
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) y( m1 z9 {" b7 r
SetTitleMatchMode RegEx
U; ^! k7 m& X3 \, O9 K3 ? return) C( F; J) U+ `) l+ v3 a. J6 K
; Stuff to do when Windows Explorer is open
3 e' v T4 W0 c3 M9 ~' X ;8 |$ H. D+ ^) {
#IfWinActive ahk_class ExploreWClass|CabinetWClass
# [9 j$ w: n5 \* }; C' |" F' A ; open ‘cmd’ in the current directory" W' O' z4 ]2 a7 A4 m/ R/ k. b
;
; S8 K3 v8 ?& y* m5 x #c::
0 k. B3 k0 }4 _) d; } i" S OpenCmdInCurrent(): v' [- r$ ^" E H/ v6 [# ]% y
return
4 E1 v" _6 [2 B) }9 K7 _( m #IfWinActive
7 b5 y, H8 j( a: [ ^4 g4 M! v* n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 `& Q. G1 c& { ; Note: expecting to be run when the active window is Explorer.
9 ^9 A3 E/ [; [& Z0 u% N8 C ;
' F2 B0 _7 l' d1 |( E OpenCmdInCurrent()- M# p4 g2 e# k6 Y: a" Z( z0 k
{& c) A0 n: C0 Z0 O, @
; This is required to get the full path of the file from the address bar, A! U1 g [. M9 @3 G. [. D8 Q
WinGetText, full_path, A
1 U& ]& a+ G. o% c) m# w; z ; Split on newline (`n)$ _! z7 S+ M1 _2 q+ `- U7 P: \
StringSplit, word_array, full_path, `n
" C8 Q- D. n* H" {: }/ [) C6 P ; Take the first element from the array! }( h0 u; V# d K; G. _, e
full_path = %word_array1%
. J. p% P- o3 ~% V* t! f ; strip to bare address
. g4 g) C$ m+ P/ v8 Q. _/ o. O full_path := RegExReplace(full_path, “地址: “, “”)2 U" `) |& ^6 X# w3 C) S
; Just in case – remove all carriage returns (`r)) N- i# h+ Q( {! n* G0 {
StringReplace, full_path, full_path, `r, , all7 D' J8 R# e; R
IfInString full_path, \
+ _$ K3 @5 T) p( i6 M {; }& a1 L O8 p6 `+ Z! E1 [3 p8 U' d
Run, cmd /K cd /D “%full_path%”$ U e& g; ?! L
}
' W T9 u" t/ U+ | i else
. k" U1 _- l+ x0 _ {
( M6 X5 [/ e4 U( h0 z# T: e Run, cmd /K cd /D “C:\ ”; @& u% J' `% ~1 H7 y
}
8 f: o; x& N$ `0 ~ }
, S: U* z y. u; L6 Y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 r/ a3 }) `: ]: e3 H3 k
这段小代码肯能有两个你需要修改的地方; T+ n# V8 f& i( @) ^
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ B4 V: j- f2 y9 G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ ^7 \- b2 H3 U4 V |