此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% U! O' B) l0 s0 T$ | a; F 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* @. x, O4 r6 H) N' ~; m 方式一:2 j; b M/ J! ? V% e z @
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, `! e( q5 s9 h/ d
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 c8 }4 \( Y! d3 z0 \/ u7 X
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" U( n1 O! r- s
方式二:- s! P1 ~( Z! g+ K1 v3 m6 H0 c
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 d. h' k2 `, Y1 @% Q; j SetTitleMatchMode RegEx
0 I3 J% M. D' ] return
' O! [; r6 z: m' C# l8 k ; Stuff to do when Windows Explorer is open
& A, L7 d5 \! k) J: M' u ;
/ |7 w; X, t( F* B4 Y #IfWinActive ahk_class ExploreWClass|CabinetWClass; x/ V5 j, L4 o$ `4 X4 j
; open ‘cmd’ in the current directory
/ P ]( n5 J* J6 C/ T* y ;
) I1 K7 J/ [7 Q& o #c::
5 o j) P: e2 V6 K4 k2 }) @ OpenCmdInCurrent()2 G% E, N1 h0 C' ?8 e- Z/ V; R
return
/ _0 S* h7 w6 S& | #IfWinActive0 U3 o. t: I/ n- W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 t6 o! K/ g& f9 [5 h* q" ]
; Note: expecting to be run when the active window is Explorer.* x! G. p$ p* O! G9 w3 b' r! o
;
# K, s( e2 @& S9 v& k OpenCmdInCurrent()
" m7 |) k; n6 a( i* L8 l4 z {
+ I, V* i6 \, E2 i ; This is required to get the full path of the file from the address bar9 \0 `( U3 g* `* f4 @0 p6 ~
WinGetText, full_path, A
& y! z4 V' U7 _! M ; Split on newline (`n)6 J7 w, Y! j' E# ^- f
StringSplit, word_array, full_path, `n
F/ j/ o V' S6 r% l% R ; Take the first element from the array% X$ G& b# ^! d" T ?; `
full_path = %word_array1%) Z0 ~# h+ P K" ^
; strip to bare address
/ i' a, z- t9 c2 } full_path := RegExReplace(full_path, “地址: “, “”)
( @; p% L! I- T5 r ; Just in case – remove all carriage returns (`r)
9 h' Y7 J, E5 V6 B8 Y: T$ E% \ StringReplace, full_path, full_path, `r, , all
1 i+ h) T) G; C IfInString full_path, \2 d% k( `% ]8 @) K/ y
{6 ~; z) j4 L! u1 h- J. J5 A% d
Run, cmd /K cd /D “%full_path%”) H/ y' @, v" n8 x: ?- C' Q
}& _3 r6 i S- b6 |
else. o5 f% o) }' {# E
{
( H' `7 ~7 `$ R# Z8 s: i" Z( { Run, cmd /K cd /D “C:\ ” U6 J+ U6 \4 n/ h
}
& ^# V* h3 i3 O. f" r5 q }
1 C3 J% Y( r! f9 ` l7 Q9 ^! L 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 u; _# a. {3 f; T: Q2 ^
这段小代码肯能有两个你需要修改的地方
7 a5 W0 x- z0 e 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 W5 C- f, Q H$ J 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 ^4 f o' s9 E1 T |