此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( g3 x8 {0 X& I' c5 N+ r. F+ f- F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! u! S- B$ `% U: \& K, ~; k
方式一:$ t+ U9 L5 w' s% Q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 Z0 @$ z" k& I0 P# w1 A9 a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) s3 e3 w- n- Q% S a1 h' z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 L; l+ ^3 a, S
方式二:
) l( ^2 s3 H7 u* C4 o 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 n4 x; f( a+ b1 ]" [0 ?
SetTitleMatchMode RegEx/ q% I8 W0 D8 E: {: k& y
return
6 H) S$ i+ X8 t. e" ?7 l ; Stuff to do when Windows Explorer is open
8 a' e$ R/ c6 L+ W ^/ h6 N ;/ b# A" l( C: ]" o5 q5 n
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 N$ g7 e) }7 n3 H. L ; open ‘cmd’ in the current directory+ i. K; X& o4 b2 r9 I0 q4 l* C( M
;- S0 [, g1 z4 Y# g) C2 x/ H% D
#c::
% Z0 D% h& r% R! z+ h OpenCmdInCurrent()
1 w2 Z- \* Q) | U return
+ I4 m7 i, t: l' w3 ]$ n8 D6 M #IfWinActive$ P: g4 R0 F, F/ W% O# P
; Opens the command shell ‘cmd’ in the directory browsed in Explorer." X4 N7 L8 {5 @. x2 O7 Q; w
; Note: expecting to be run when the active window is Explorer.' Q& O W4 ]2 m; o
;
, `8 [: E* P7 ]" r' R OpenCmdInCurrent()+ b* M- Z0 N: z. J# Z
{2 B7 `& y t4 [" ]7 I) l
; This is required to get the full path of the file from the address bar1 I% c+ X0 h9 B: F. P
WinGetText, full_path, A
. g; t0 Y( z$ Q+ b5 G ; Split on newline (`n)
6 r |3 w6 j8 D$ Q StringSplit, word_array, full_path, `n/ t5 q/ j1 I* T8 s0 R* j5 [8 _2 F. h
; Take the first element from the array
7 h, f7 o% V7 d full_path = %word_array1%
7 |" h4 q; f0 l0 B ; strip to bare address6 ?: ~8 F; W( r g% A0 W
full_path := RegExReplace(full_path, “地址: “, “”)5 ~. Q+ k2 z7 A) B
; Just in case – remove all carriage returns (`r)
$ z7 K, `8 J6 j+ Y StringReplace, full_path, full_path, `r, , all
% R# l1 H: Q, z! y0 x; j1 v. u IfInString full_path, \
' ^' q5 i1 o4 E5 o% G {0 X( J, @7 T+ M! {
Run, cmd /K cd /D “%full_path%”! V; J9 Y9 K* m; U, p& |4 {3 w* }
}
' c3 {; j, r! T! A else
/ ?2 z7 e; X; O/ L) E" u6 @ {# C3 H9 S, p r& g
Run, cmd /K cd /D “C:\ ”$ q; |& {. J! y
}
2 u3 R; ^9 E7 H' I. @' ~" Q8 h( H }$ W8 u, l z+ {9 z) n/ T. ]# R
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 r; t# ~) H, `7 v9 P1 N, Z& j4 n 这段小代码肯能有两个你需要修改的地方+ y2 o8 ^1 t+ Z- K
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" p5 l* M0 E' T: w
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* t' L$ V* Q1 N9 l: r1 C8 N
|