此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 j5 S. F0 _8 R& P3 e
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' K* @% \ a# x0 D3 z% h
方式一:
, _7 I* l2 G' I: n. V- k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& b9 O' L( _' ^' q$ Y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, {' n. g# B% s) K3 `9 A HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 Y$ ?- [$ v9 R( d" t0 z, K
方式二:8 T% u/ A u- c8 f1 O4 [ k! u
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 K6 p# v" I r# u; j SetTitleMatchMode RegEx1 ~& O- }7 ~9 `& `. u" m
return% m9 m9 j! _" Z, B9 R0 r) b
; Stuff to do when Windows Explorer is open2 _# Y; q( N7 G. p; f7 m
;
9 s- {6 N0 r3 B! ^5 m #IfWinActive ahk_class ExploreWClass|CabinetWClass. ? l, {) d% _9 c- {
; open ‘cmd’ in the current directory' b# \: M* f. n, p; Y( h, K8 f% q
;
/ {' M5 y/ B6 z" V( h/ | #c::
; {* p' k$ F; r2 J4 a+ ] OpenCmdInCurrent()
y8 d$ N" K) [$ Q f return
9 D" S+ \6 q, }" d% q. e2 f #IfWinActive% E. ~$ r. i; ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., i' v# }- I. z/ e& m) {5 q4 k9 P
; Note: expecting to be run when the active window is Explorer.2 {% ?( q5 N- Q
;
# R+ A. J R3 [ d5 A- H( I OpenCmdInCurrent()
6 }7 D: X) O9 m. S+ r6 \/ H2 \ {
: X- d* [' s9 _( G, V: w7 W ; This is required to get the full path of the file from the address bar
' n- X1 m1 {/ e- _- u+ ? WinGetText, full_path, A8 u3 S; K& a. m( o; |$ ^ ^7 y
; Split on newline (`n)7 ]" I* t/ g; q! m/ `. v( W
StringSplit, word_array, full_path, `n* [0 e' n* ~9 w, W ?: p
; Take the first element from the array6 ]/ M4 U3 f% L& d1 `9 x& h8 f3 _
full_path = %word_array1%2 a0 g7 b7 |. a+ y" T2 x3 f( ~
; strip to bare address
8 ^2 m% b3 d' l% l7 c/ z2 J! J full_path := RegExReplace(full_path, “地址: “, “”)1 Q9 D: n ?0 t$ E8 Z4 N
; Just in case – remove all carriage returns (`r)
+ g( Y) O3 ?" I0 |0 U StringReplace, full_path, full_path, `r, , all
0 z; e1 a" m4 W" U. _ IfInString full_path, \5 \% h& b: _# L0 h0 t( u
{3 u {" p1 ] b0 @- L
Run, cmd /K cd /D “%full_path%”
! f# o% x: K3 F }1 r T5 E/ z6 O( C7 l6 N5 \
else! f: w8 T1 t3 U0 C; L# P
{) Y P8 k% d& ~9 J. m$ v
Run, cmd /K cd /D “C:\ ”& `1 ~# u0 B$ }! F5 I) w. E
}0 }5 a- P3 B' g/ h& I
}) h1 ?% x) U: _8 J3 b- f
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; f: K! \9 D% a7 w5 J 这段小代码肯能有两个你需要修改的地方/ S) _) j1 } E5 s
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& g& H( k5 H. O; \+ M+ a9 i, S* M
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 ^- F2 ~: B) _6 o# H5 A9 x; J
|