此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( K( a3 j, ^; q; X4 t) q, a7 M3 ~
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% J; E K& n, p
方式一:
& O1 g6 c9 C+ g1 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& `4 S. w% I @6 X7 q: |+ H
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 C: ? s6 S' V6 f2 J
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ V* P+ ]0 y# j, A
方式二:/ V! W2 T! I: h/ _- r7 x
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# B( c* k& y$ J. U! v- C
SetTitleMatchMode RegEx% N. b3 {8 {( k9 M7 Z+ p
return2 h# Z/ F* k: r7 ?8 i
; Stuff to do when Windows Explorer is open
4 L7 U" ^7 p& z9 A" y ;
* {! b+ M, j' c @ #IfWinActive ahk_class ExploreWClass|CabinetWClass' [5 z: i4 ~: b" \+ G
; open ‘cmd’ in the current directory2 m4 G( b" Z( i' t5 \ D
;
2 b+ U ?1 c$ D$ e( k #c::
7 p O# O3 K3 M OpenCmdInCurrent()3 i% ~2 d9 {6 i l% e" D* A t
return
' t* I$ E& M' W, X# d4 z #IfWinActive
. f* r' W5 r: B$ | ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% d* l3 _, J g3 e3 `6 ]8 L: b
; Note: expecting to be run when the active window is Explorer.- f4 x1 ^3 B% s! Z) I
;
" s1 r& E" X! k, A% i" K/ P OpenCmdInCurrent()4 h/ w# F3 P) z% Z4 P) _
{
) q* W) ~. I6 S y$ K% D6 c2 ?5 f ; This is required to get the full path of the file from the address bar' w) c; b& H' D: o/ n. S, F) }
WinGetText, full_path, A2 L2 _5 Q+ T/ N, b* g# t) O
; Split on newline (`n) e2 g: ]# J# m3 G% Z
StringSplit, word_array, full_path, `n% R* A( q6 m1 Q) _: p
; Take the first element from the array
8 t1 S6 s ~0 K6 _- ^ full_path = %word_array1%/ o5 V+ ~, i' ]
; strip to bare address" @) [0 s$ N- T2 n; L! c
full_path := RegExReplace(full_path, “地址: “, “”); A N- ?1 a7 s! N3 j
; Just in case – remove all carriage returns (`r)+ w$ t: O( A w; j; `) [- V# e
StringReplace, full_path, full_path, `r, , all
& g O: p0 n* @0 q IfInString full_path, \& ~/ V" `6 A+ ~& f( d8 W& Y: t
{
' ]! j* {" }6 `8 m( f; N4 y Run, cmd /K cd /D “%full_path%”
& u5 b; j. J7 t/ A) c2 t. d }, a% E. V1 ~6 ~: G9 `0 w
else
! e) d, f" ?( Z- l8 ~1 n+ s {
3 k* P7 T0 m2 T% Q9 g' z- o Run, cmd /K cd /D “C:\ ”
{! Q& R8 L, O, [$ t# f. t }
1 i$ `9 ]7 ^! }, D) ? r4 U }
8 H8 f, w0 H f+ d0 U 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. H) ]" a+ v1 a F. Y9 a2 t2 A9 x 这段小代码肯能有两个你需要修改的地方2 o+ G; L U6 R; N
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* ?0 T+ l6 z' v+ n* T% b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. i( C% P7 [ \3 C3 C$ A
|