此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) s; r2 R- F! t' i6 G* u
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' W/ p( N* f+ G. ], v: F
方式一:) a, i6 \ ]. w( @( D
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# x5 O; Z! {0 D7 I% [
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' a, q! ^1 \' E K7 C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* U4 i" Y+ d7 t2 o# h! Q. w 方式二:, R" V) L& z3 y' k! D# M
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ O/ i+ X6 Q' N7 R5 |: ?" c
SetTitleMatchMode RegEx
* h# s% P& n7 Y: B2 o3 j0 @9 ? return
* m7 u1 ~1 j5 u3 P ; Stuff to do when Windows Explorer is open
& n) z. q# |* L+ M& e" V ;
- X1 `- u+ `. ?8 V #IfWinActive ahk_class ExploreWClass|CabinetWClass2 ~/ w# t1 p! R% G' X% L/ |- ]
; open ‘cmd’ in the current directory* R9 g# W8 K: F) _+ O# x) ~! D; C5 `
;
4 @7 Y& z1 T* w' d #c::% [9 _) a0 k. y8 J; w
OpenCmdInCurrent() H# ~0 E z3 g* m+ d0 q, F
return' v9 [% |6 ?0 ], k _
#IfWinActive, I: X6 v# A2 n: B) h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& O8 u; t |- O6 J' p! M* E
; Note: expecting to be run when the active window is Explorer.1 [1 m( X2 Q5 S
; S) m, U- ^' d3 t. {. b* ]4 o
OpenCmdInCurrent()# O/ {6 p) i U- z: T7 n
{: o5 k, t% W; N$ o
; This is required to get the full path of the file from the address bar- W% j3 m6 V e, r
WinGetText, full_path, A
+ X K' O" n" R: ?! A ; Split on newline (`n): n& M% P- z. h8 c, ~5 x7 X
StringSplit, word_array, full_path, `n' I1 e/ Q! J$ N8 F; x# f
; Take the first element from the array
4 g" Q9 E; k6 j. @9 |2 P% a: C full_path = %word_array1%6 G1 O' Y; H; G' k! W& z
; strip to bare address
1 q# ?0 G6 s7 p7 H full_path := RegExReplace(full_path, “地址: “, “”)
( u0 w4 f! V9 N- R% p- N Y* ?5 o ; Just in case – remove all carriage returns (`r). w. g: w- p4 B3 F/ c4 U
StringReplace, full_path, full_path, `r, , all
) {0 o+ u. {2 i7 l0 P3 Z IfInString full_path, \
* d/ ?. q/ V) H f7 J2 E {
/ [6 b! V- N% _: t' j( ^ Run, cmd /K cd /D “%full_path%”- I Y1 T7 z* V# p* {( l. D
}
0 I2 b- V" O t; l" d' q else
D7 M: N! ^- }5 P( _; ]. d {. B @- P8 N9 P+ a3 P* e; V
Run, cmd /K cd /D “C:\ ”
" r7 c/ T0 x( n& z5 G; V" e }
$ U$ E" q4 N! U+ Z. e1 l7 M }
5 i$ p! n; Y( ^( }: i. g0 e: Q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 R) l, H+ B/ M) S
这段小代码肯能有两个你需要修改的地方' A! |: ]' p3 P
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! |1 ^" I: I' O* X5 v
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) O) t# o4 V6 i
|