此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 w5 I% Z" o9 r8 g. {/ U3 t 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% K( {/ F+ y0 g# V: I e* L
方式一:, ?" _% n" Q" e2 N0 `. f
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, N: J4 j2 t* Q5 B, [
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 r- t+ J) W1 r6 S& C HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, t' u% e* A% N, g/ j& o 方式二:3 T7 ?) C& U; _2 V8 L2 P
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 ]& z4 q9 H$ ^/ ]* b% v
SetTitleMatchMode RegEx
) x# E: x& V o w# {7 p9 S return
) V6 b& q( K% Q% q ; Stuff to do when Windows Explorer is open
3 u0 i) M8 R2 X8 D ;) L0 M2 G) z# x$ l1 w
#IfWinActive ahk_class ExploreWClass|CabinetWClass9 Q N! N- ?6 S5 f
; open ‘cmd’ in the current directory
- o* Z ~% U. P: e) o- j ;
. c G* _9 B8 ?9 E0 \ #c::
( F; D* |% l! V" a OpenCmdInCurrent()
: A: ?/ Y! L7 t+ M8 E, J8 f return
0 o" L* v& g. t+ S #IfWinActive
: C* A$ ]6 V& v9 V: o4 b: _+ \) p ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 m( v% \" M; x8 f0 x
; Note: expecting to be run when the active window is Explorer.3 Z8 M/ i# O) m ~% S; L3 a
;" L+ [* t9 h$ ?) B* C( t9 x* K
OpenCmdInCurrent()
+ _# C) L: a$ }& s6 W {. T; ` s' X% | f! ~& z+ j
; This is required to get the full path of the file from the address bar5 K( p+ R* E0 i. |; U6 V. [
WinGetText, full_path, A
) q3 J2 r7 g, t4 I' Q6 J6 J ; Split on newline (`n)* d; q* V) u5 C1 E. `, U2 f I
StringSplit, word_array, full_path, `n
& h2 q7 y2 D3 T) R ; Take the first element from the array, A" g& E2 r% p1 ?$ \& C2 ~/ p7 c+ p2 m
full_path = %word_array1%# b. x Z ]6 |0 |5 \
; strip to bare address: t3 {: K H0 b8 V' X5 [) `
full_path := RegExReplace(full_path, “地址: “, “”); u9 Z/ ^5 u/ x6 U1 }* N4 E
; Just in case – remove all carriage returns (`r)
5 x+ A2 A9 N0 k5 d; D% z8 f StringReplace, full_path, full_path, `r, , all& S) y2 ]8 C$ K9 e
IfInString full_path, \
' K1 ^0 X6 Z2 A, \7 R, {$ N {3 _+ W/ r& R, E: q# V
Run, cmd /K cd /D “%full_path%”
4 a$ @) b/ S2 _: V" } }
) [, O, H( P, u* w# n# T6 f* n9 i else
4 L0 }% @0 \) r8 c% Y+ s4 ?; O {
1 Z$ @/ Z9 M }+ N: ~* H Run, cmd /K cd /D “C:\ ”8 \" T; q" x& B* C0 h3 b" ` t
}
$ f; J+ j8 ~% p1 X/ { T }
) B) w: @5 F1 Z8 k& j/ W5 k 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
5 m3 z8 A* p6 K3 c* ? 这段小代码肯能有两个你需要修改的地方
0 l& p9 L8 M' B P; C, h 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ p9 Z" q1 A! o) N# j
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. A1 c6 {- V1 U. f, V( X
|