此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 O, t% D4 L( X7 Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
F: F+ D% r V4 j( | 方式一:
4 L7 x: V0 X1 N$ P y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 G! C7 y! J- g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) u+ ^ I: C4 W( j2 d- j% H
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 ~3 u" b+ Y& x0 c
方式二:- V. Q; _. V- l$ J+ o# D2 O+ p
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. t0 y- d# q0 [, \1 n1 u0 @6 k4 ^
SetTitleMatchMode RegEx d( D0 q2 ~7 w1 U9 R2 O2 b
return1 c/ w0 A5 o7 A
; Stuff to do when Windows Explorer is open4 s$ K/ f b" b1 l2 W
;
0 R% y* l8 a+ l1 o& d% G; Z #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 v; |9 U5 o9 a1 K ; open ‘cmd’ in the current directory0 ?- r3 P2 ^. a, Y
;! i" J3 q8 v/ [
#c::
) W3 o/ a: t/ K& w! F8 N. ]9 i3 ] OpenCmdInCurrent()) B6 k3 P% O/ W
return
7 r x# U3 c. z+ k: @ #IfWinActive
) J6 E- R8 Q. ]' i2 s: ?4 f ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' H: y- X* j5 B$ N ; Note: expecting to be run when the active window is Explorer.
o2 G; k$ }! f ;# A8 ~; k' A+ W
OpenCmdInCurrent()
) J5 c) n5 o, t {
D2 J" [( m7 J ; This is required to get the full path of the file from the address bar9 J$ I+ \! y3 m( D& C
WinGetText, full_path, A& k& L: _/ X( s: s
; Split on newline (`n)
- {7 E/ d( m8 G5 b StringSplit, word_array, full_path, `n- v) c) \! u8 r$ a" Z
; Take the first element from the array
* ^& b; X$ ~1 h: I" @3 g, T full_path = %word_array1%
2 t4 X' [: {3 v6 A$ o/ r. L+ U! Q ; strip to bare address
5 a! s5 X ]9 j; z full_path := RegExReplace(full_path, “地址: “, “”)" F6 _& N+ U- _& Q' |3 ^* k
; Just in case – remove all carriage returns (`r)
4 x- Q/ ]. X2 s4 b& ^ StringReplace, full_path, full_path, `r, , all* e8 w5 `5 [& V1 R3 E4 r( K o% G
IfInString full_path, \/ p7 z; b! z( N$ g! d/ L
{$ E8 R; `2 Y4 I4 X' H3 g7 q1 t2 z
Run, cmd /K cd /D “%full_path%”
) a! ^3 Z0 ^6 K }
) _, X2 X0 x/ n9 |5 l1 m else1 h5 `; \! q4 X) v
{
$ b; q" u& w+ r! R- f6 y Run, cmd /K cd /D “C:\ ”1 t b+ T( @& P
}" Y* c& u p6 b
}
; L: n; b. L' N, q6 B 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) ^; B0 ^7 w& f3 Y* H
这段小代码肯能有两个你需要修改的地方/ a x/ w+ `0 b$ _5 X0 z; T5 C
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ A* u6 h) r( |+ }1 f0 x
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ h$ j4 v* s1 f3 F" \
|