此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# d' A0 @' x6 j$ W& {& _/ y 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 j `% P4 n5 U t3 T8 @
方式一:
9 N6 z7 P) c. G 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# l0 Z1 m6 C j s% a7 H
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% d. ~4 v4 g2 j; h( B* [% I
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, F. i% D! Z( }" d) M3 v
方式二:0 i' v4 H2 L5 j6 h1 y7 k! B+ Y# ^
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
z$ a' B, ?7 @* Y( u% c7 x3 Q SetTitleMatchMode RegEx @5 Q' x8 ?( Y+ r I; U' U' g. }5 W
return% V b& z( O7 ]; [9 C" ?
; Stuff to do when Windows Explorer is open3 F* @9 @- O9 Z3 I- W- P$ c; E0 h
;: Y; O7 m4 A# u) z
#IfWinActive ahk_class ExploreWClass|CabinetWClass! r- G; p/ F, B
; open ‘cmd’ in the current directory4 {5 p7 n; ]$ O2 W2 n. b
;, R( Z: \2 Q) e. Q( V: w* d
#c::
. {0 _- p+ W* m. T8 o: Z OpenCmdInCurrent()
8 u8 [7 v1 f# G return l# X2 |7 a# Y1 X' M- d: M0 U* q
#IfWinActive
4 z! r& r1 _' X( o ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., {( Z# l; A+ ]( u
; Note: expecting to be run when the active window is Explorer.
% F0 d& P+ E* S; V3 i4 q3 O& m ;6 v4 K# _; ]! ]0 i- l8 X/ L
OpenCmdInCurrent()
& m7 ]7 A y- U3 B' I1 m, T {
7 D7 S( I6 ]# U9 Y1 W1 i0 J ; This is required to get the full path of the file from the address bar# I- t- A* _0 ?: r" z( h+ O
WinGetText, full_path, A
3 `1 p, d# h6 k; t ; Split on newline (`n)4 p, o/ X# ^* [' Q
StringSplit, word_array, full_path, `n+ J. i3 p. |% T8 `
; Take the first element from the array
. ~% e. N8 V! V6 o full_path = %word_array1%
( v# |/ |. @6 C6 W8 C ; strip to bare address0 ?3 f# h- T* j- o) R% @7 L
full_path := RegExReplace(full_path, “地址: “, “”)* h: q# ?$ A9 R9 Y
; Just in case – remove all carriage returns (`r)
# J# }$ k, D/ i/ n5 T* M* i6 n StringReplace, full_path, full_path, `r, , all
& P: l, p, U5 ?) {# u7 r( B IfInString full_path, \) S' z" s0 l; q4 F# _8 f# ]
{1 ^1 [3 Z0 I @3 @: ]
Run, cmd /K cd /D “%full_path%”
7 `$ x* k. K' K }% Y' B E) D+ p3 B, w y* o6 R
else2 q: S. y. ]& u- h
{9 k# ?) b6 x' J d; m
Run, cmd /K cd /D “C:\ ”2 d7 w S, o1 B
}
# R( f3 U( A6 }% H- w( w% q4 b }
1 y G( d+ y; G* K" b% Q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* H$ U; U( {7 X6 l9 X& F( A 这段小代码肯能有两个你需要修改的地方
N. b" V' c& Y n0 x+ } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, `3 K1 j# o, F. g 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! [+ f7 N3 b2 L* S7 p2 ]' I
|