此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 j. Q! F+ k/ \- j6 J1 P$ _ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" j% V( @* }( M& N) [# r: R. f3 [ 方式一:: ^- k4 I0 i1 ^/ i: P0 u# d6 w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& j& P+ r8 s4 Y; D* q% m3 `
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& h2 D* x5 o: s) h5 X S9 g2 ^+ I/ k1 W
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, h* R2 d0 y7 B) N+ k" v
方式二:
* p( N5 A$ a) Q; f8 A9 ?; m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" p1 k8 l* d/ ^1 t9 a
SetTitleMatchMode RegEx
$ c" G& k: g3 M3 ` return y' K% q( a, p
; Stuff to do when Windows Explorer is open
) G! ~( u, b3 ] ;3 C8 t/ n, \+ {6 L; e$ z1 M
#IfWinActive ahk_class ExploreWClass|CabinetWClass/ ^% m7 m& |# s
; open ‘cmd’ in the current directory
7 O+ O& X2 o- x% b( I ;
. E/ v/ M7 W' q: w' z #c::3 N# G# h0 e: z- S
OpenCmdInCurrent()3 D+ B. J. _) x) [, O
return
r& R: \: u, J! ]* s1 ^ #IfWinActive P; k6 e" c4 g
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) q. z# C& z$ h, U
; Note: expecting to be run when the active window is Explorer.
$ Y& n( X3 Z- w1 t, l3 H1 ~- S9 z" ` ;5 e! U5 b$ d" [: j
OpenCmdInCurrent()
& n( m$ L v! b4 F' p* k {
2 p* A- T: i, r1 d9 _ ; This is required to get the full path of the file from the address bar
& U/ s/ l, b* l WinGetText, full_path, A8 }5 R5 w+ J" y) s2 f2 R
; Split on newline (`n)
; g. [$ M. a# ], E+ o StringSplit, word_array, full_path, `n. ]7 i9 i1 s7 B/ f0 m
; Take the first element from the array8 Q) U. a* u' ^
full_path = %word_array1%
6 p. y) N2 d) L5 q+ { V1 {6 h9 m ; strip to bare address6 e X" D6 ^! a3 m* _6 P
full_path := RegExReplace(full_path, “地址: “, “”)& }; G% z& S- Z" z. G# P [
; Just in case – remove all carriage returns (`r)
% t: J u w' k9 F StringReplace, full_path, full_path, `r, , all
: ^; Z( ]6 `8 |" V IfInString full_path, \+ B' J( I4 W3 j' D8 P4 R' c
{& @" d6 G4 f5 \" n8 ` n+ {! ~
Run, cmd /K cd /D “%full_path%”
6 T% N( h. f1 |) D }% L! }9 \2 _7 N3 d% Y5 J% D* K$ ^" [
else3 i. f+ Z! s3 {6 e4 k( J1 S
{
5 V+ |7 f" E% M9 r1 q6 s& X Run, cmd /K cd /D “C:\ ”
6 Q8 I& p$ t+ w7 \/ F; C% e }
% Q" ~/ c8 f( u0 }. H* w; C. } }+ B. G3 m+ M% }- \0 @1 O% e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" s1 j& z" o' R2 c) a f 这段小代码肯能有两个你需要修改的地方8 h" V; p- \) G3 E* p% O
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% i \0 G4 t( T/ |- L4 ~; \ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 b; W5 `9 C( _1 d |