此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 Q' E* K9 P: M% Y- \ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 F: Y2 S1 k: y t, [) z6 O5 T
方式一:( L6 [( Y P' |% J+ R
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ U. }4 H6 g0 k/ d4 m: ?" P
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) a ?( i) {" f2 `$ L" }6 D' B6 N
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% F/ d' x" h W! r
方式二:
3 u6 j5 }& F1 _4 v' P 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 z3 A) @( w+ }7 e" f SetTitleMatchMode RegEx
. r5 a" v( F8 o5 O0 L; i return
0 U: }+ X/ L, K3 z& b+ m, [ ; Stuff to do when Windows Explorer is open
, D8 b; k) u7 }) O3 S ;
, A. i1 |8 W2 G, ] #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 G# t9 a0 d; V/ ? ; open ‘cmd’ in the current directory
: Z! G* K7 h/ C- G3 g ;
. l4 z$ ]6 F: ]/ e; D! a #c::: z- H, L U. l
OpenCmdInCurrent()5 X4 ?2 \1 Z8 }! w2 W [
return
% }* r' d- _7 C0 x5 [ #IfWinActive: `3 R7 q& K- J
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 W4 m$ ?) C$ ?! I, t ; Note: expecting to be run when the active window is Explorer.6 v; t4 q" m; J6 ]6 `3 q, U
;
' v3 \' N) G" A& g" y6 l5 K" i OpenCmdInCurrent()
( b6 W! L8 c; {6 y, n {1 F2 d$ l$ C: x
; This is required to get the full path of the file from the address bar Q% Z* ^9 J; v4 T: K5 f
WinGetText, full_path, A, M) X! q7 Z& J" c. y+ q, o* H
; Split on newline (`n), Q3 B$ m' ]. A: h
StringSplit, word_array, full_path, `n
2 F- h/ E! ]' \2 H: X- K ; Take the first element from the array
; N# o5 S+ H5 b5 ?9 E# } full_path = %word_array1%
( B) B6 }5 ?) v- [% q3 }: n$ F: E2 L ; strip to bare address
V }/ ^- P- a full_path := RegExReplace(full_path, “地址: “, “”)& ]6 Z8 t' k& Q* Z3 ^3 R
; Just in case – remove all carriage returns (`r), E5 Q, n% i4 i7 H- ^1 u e5 T
StringReplace, full_path, full_path, `r, , all
0 A4 \; _" |9 V$ r2 v$ d5 k2 a) L IfInString full_path, \
2 e+ H6 t) I, E) O p( S+ M {
5 ?1 V- V$ f" E' K" K) z Run, cmd /K cd /D “%full_path%”
/ x7 p, g7 _# r# M% l' `# m5 } }* F- i, K5 J1 F5 i1 w9 f3 c! T9 W
else' S( a4 L! ^0 b7 m6 i
{
! K. J0 m) b; L. _0 i! u9 j/ h2 V Run, cmd /K cd /D “C:\ ”
F; i: F1 v( D3 }2 j' H0 { }" m E$ e5 H$ F9 ^5 [; Z
}
1 r$ `+ t, @9 Z' T7 U( h' f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* `8 [, n2 g8 s$ K 这段小代码肯能有两个你需要修改的地方
% C& A/ ]1 [1 h/ N 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- H" T: L2 b1 C7 q! [/ j" Y8 `5 q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' f& p* ?8 y' |* o8 V! m
|