此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; J& d6 _% q6 z( P% T: ~ R5 M 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, o3 O: [7 ? O7 E# i# q
方式一:' X" e1 o4 U \$ ]
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) O/ R' U4 F+ d( A& P7 K5 P/ ] 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; u6 y- w3 ^7 @% w$ {. e HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" K- g4 `2 r7 C/ Z% b+ e 方式二:# A3 r @6 m5 x# |' h0 z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ y: n2 l0 g- Z/ H$ c SetTitleMatchMode RegEx
8 f- N; S8 E9 t# V0 ^ return. M. y+ x. R Z2 c' H4 r9 r
; Stuff to do when Windows Explorer is open& o- z! p# M. Z. H( E; V) ~% L
;" K, i6 x8 x; j/ B" W+ ^* [5 `
#IfWinActive ahk_class ExploreWClass|CabinetWClass
2 v9 K% Y# v2 h n' J ; open ‘cmd’ in the current directory
" g. R8 P4 ` S2 o5 d* | Z Q ;
2 Z7 ^- F- P4 c, F #c::
1 B: K7 j4 E6 h" ^* q) h) S OpenCmdInCurrent()( `- C3 Y, e4 ^5 i( u
return
( Z; r- u9 \; [; U #IfWinActive
& x4 S+ S( i: R: s6 t1 @- v, ?% l ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: n8 T+ a5 w3 N3 n- x9 R* H0 A5 s ; Note: expecting to be run when the active window is Explorer.6 w- K$ x) `$ `. \; l: I3 D3 O
;
+ [4 [+ g# { V, r2 c- I$ l OpenCmdInCurrent()
- I$ z {6 [6 d6 \1 n& X$ ~+ @# { {" G0 r2 x; H! R$ ~
; This is required to get the full path of the file from the address bar
$ W0 Z0 @0 k9 c b8 s WinGetText, full_path, A
4 j! f& C1 e; n/ w' l2 @ ; Split on newline (`n)
4 S: y# K+ b H1 y# x0 x StringSplit, word_array, full_path, `n& j6 U& D; j0 P2 h1 J2 J# A5 C; L8 v, D. w
; Take the first element from the array j4 t. @9 i: y
full_path = %word_array1%% c, R% v1 a( o% b) Q V/ _$ [
; strip to bare address. _) `& w2 O3 _+ C2 L3 B
full_path := RegExReplace(full_path, “地址: “, “”)- a0 e" W4 }' ~
; Just in case – remove all carriage returns (`r)
# L) _2 n9 u* C% {$ O% g0 C5 }8 E8 B StringReplace, full_path, full_path, `r, , all
# D" Q# v6 F5 F7 ]* Z6 g! R IfInString full_path, \
8 d6 Z6 k" _: O x {
' c! Z6 b* a- A1 U& N Run, cmd /K cd /D “%full_path%”: f$ n* A% @- ]3 F
}
& x9 N, `* k4 @7 V else5 F. |0 ^6 A% f5 |
{% A$ n; |3 V' G
Run, cmd /K cd /D “C:\ ”
9 q; I. Z: }5 H- t2 M2 v5 ~2 S }
! ?" b/ c8 G1 O! I }
4 Y; P+ S; d+ _4 j- v 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( c! A5 N' v$ M& C
这段小代码肯能有两个你需要修改的地方( S: N8 y, [, w
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. e3 G* T# e$ T6 U0 ~: i6 r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% M& P4 C, I! \* i2 m2 t; ? |