此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- N; Z, }, L8 f2 H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 i* S% p* s% C" g
方式一:. P O% g% P" P& f
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 ~! @9 H+ p6 l& g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 D5 v. Q P/ [: L' p2 e" P; i HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! b! j* M" @; k; K; L' s! C
方式二:
6 Z7 W' [3 w" O. e8 O7 i2 ~ | 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 Y( g; }- s0 K2 V+ d$ c SetTitleMatchMode RegEx
) p! @2 ]: M7 W, l+ B% u) I* c return
; |0 `/ a/ o" Y& R6 @( t* G ; Stuff to do when Windows Explorer is open
* C% ]1 S* y" s7 ]6 c1 X! x ;
$ l) _7 Q }* X #IfWinActive ahk_class ExploreWClass|CabinetWClass
' _& c3 ]' c2 X9 y. f8 `8 t9 Y. W ; open ‘cmd’ in the current directory' d$ z, M' b* C& k ]* i4 S O) p
;
2 j9 c6 {5 b$ W7 s; ]+ d #c::4 }% }, P: A$ q9 V) @" V
OpenCmdInCurrent()
4 k+ X/ X1 P7 @8 D; C4 t return
2 j0 K" a) z1 _2 m6 g/ g #IfWinActive5 Z" G! x4 a4 W# _2 ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' W2 p- `1 W1 t0 U
; Note: expecting to be run when the active window is Explorer.
1 y8 {7 M( L& o6 t ;2 c2 O# ^: O$ |5 w5 R1 @/ H. B& B+ s1 c
OpenCmdInCurrent()
]9 Z# @1 Y2 s' t: j {& S; t! j4 c5 `1 V) I9 p
; This is required to get the full path of the file from the address bar
# A7 ^4 Z! C0 \5 ?% H8 c, Y; v3 M9 m" l WinGetText, full_path, A
" _, @- `) ?$ { ; Split on newline (`n)
- C% n) C( Z5 g% Z/ ^3 y StringSplit, word_array, full_path, `n
5 X9 H% Y9 G9 @. J6 N5 c" [* g ; Take the first element from the array9 Z: X. d- {* f% z9 r$ f. q: P/ Q
full_path = %word_array1%
% S, ~" N5 u; {* b3 l2 C ; strip to bare address$ {; Y U! U7 l ^; z1 v
full_path := RegExReplace(full_path, “地址: “, “”)7 Y" t6 y" I, D' R% i- m
; Just in case – remove all carriage returns (`r)
% R+ ^& i; Q0 b& S, x r5 @6 Y' v StringReplace, full_path, full_path, `r, , all
) U# D- x2 l; \6 Q- Y' s IfInString full_path, \1 M) a! P1 b) I9 C4 k! l' b, W
{
, _6 ?3 u0 U+ u1 x% i- H Run, cmd /K cd /D “%full_path%”, c) |4 C! |: o
}: J! [/ M) K4 L; y" F+ Z( U
else+ w: J' W5 {2 |; w/ o
{
1 n, g: Y, H& \6 [: p. y' r2 ] Run, cmd /K cd /D “C:\ ”8 p- B! h' X, h* G
}4 J& n2 I7 O7 O+ s; {3 d& ?8 v0 z! d
}
; U4 P2 O( m% c* B* Y9 t. j 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( ]' R, K. T( P X$ G7 L, Y1 h& i
这段小代码肯能有两个你需要修改的地方' r8 y6 d7 J, V! @; a/ d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( \- H; J' [- u O; H! K' B 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 P% ^1 G2 C$ \/ a/ p
|