此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 E, r0 |8 p1 S7 _% C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 C1 z$ h7 I- G# A 方式一:- L u' q5 _7 |
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ g m8 j2 w( N; D2 ?9 T& s( P
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' N2 V3 |, d7 f: H HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) x+ u5 m/ a6 X5 T' W 方式二:
! g1 U4 |# c2 f# K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 U4 l- t4 f$ K- C2 U/ I: _
SetTitleMatchMode RegEx8 |2 k) S }' b. w6 t" X+ z: `
return8 Q: G# u& i$ X) l, H& d) S
; Stuff to do when Windows Explorer is open
; J% \# P' [$ Q2 P N ;
; f: y8 t1 X3 p7 c$ B+ \1 Q #IfWinActive ahk_class ExploreWClass|CabinetWClass4 n3 e7 U8 g W; ^' J$ p7 `3 ?
; open ‘cmd’ in the current directory c9 S4 v1 o$ M" ^
;% {, s& ^% R7 z1 [0 D
#c::2 R) T. W" t" H( p; R" c
OpenCmdInCurrent()! o/ i6 R2 l0 I5 l( G3 h* q- L
return, p' n) p4 T9 A' [/ Q& W
#IfWinActive0 `! O- o' n/ ^1 X
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 M7 ]2 N7 v- X( V; `8 h1 h
; Note: expecting to be run when the active window is Explorer.
& s2 E; w4 W1 g7 ?/ l: I [% b8 E ;
8 T$ z* {" D+ y! k OpenCmdInCurrent()
4 v! |$ `( Z5 ]% v( u {7 R. h& ^3 g! \: V8 d
; This is required to get the full path of the file from the address bar8 X B$ I1 x+ `$ w3 L/ x! V$ m" ]+ H3 P
WinGetText, full_path, A& Z; G: w6 ?$ T+ J7 J
; Split on newline (`n)
r3 _$ J: J V# V. I) a StringSplit, word_array, full_path, `n
0 \% G3 M9 z; C. ~8 G ; Take the first element from the array
5 Y$ N+ K. E* N3 M% M; x5 Z full_path = %word_array1%4 u' d, E2 j4 f& q; }% M
; strip to bare address3 }6 l7 q( k9 k, W" y" I
full_path := RegExReplace(full_path, “地址: “, “”)
/ ~; L- S* Q0 {( R7 W ; Just in case – remove all carriage returns (`r)
9 {: T+ b, P1 m& Y- Y( P' ] StringReplace, full_path, full_path, `r, , all
$ v$ I* h. C9 f+ q IfInString full_path, \
) n# o/ p5 M/ R9 w' S {/ R8 Z3 K5 R+ c+ o' O( y
Run, cmd /K cd /D “%full_path%”- I) S6 T/ g1 Y
}* c& r% n9 \; ?+ O/ L5 H' F; ]
else! S7 h' x# C6 v0 n- P4 z, h* s g
{
( }; d6 t# r3 P Run, cmd /K cd /D “C:\ ”5 I- ^9 i4 n+ j
}! Z: L" O6 {! [2 ^- s6 [: P
}( Q. O2 |" z1 {% C) ]: m' J
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 e- A4 s( x% v3 N* s; F# E
这段小代码肯能有两个你需要修改的地方 d; l: r6 B0 g, F" W' |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 `3 l1 c( M: d2 A( ^1 v 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, Y2 R7 v+ S- H5 ~& q
|