此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% o7 ^# x3 G* y1 o% Q& { s
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' X! W! Q: g' g 方式一:; B; E$ ]0 _+ h4 k
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! f+ Y3 H, C% [3 O4 w% J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; w, @( m6 L4 ~) Y x
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- ~, p" R7 L. W. B1 U5 Z+ y+ ^
方式二:
! d1 R/ }+ @! h z: K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, C' d) M/ S/ a/ Q# @& q+ I SetTitleMatchMode RegEx: i6 j' A; N* {/ s) b6 r9 n: s
return. E- V- w8 G% M8 c) ~, {0 w
; Stuff to do when Windows Explorer is open( p3 m7 |( g/ |4 U. E% H/ Z6 |
;
3 k6 C, R7 f \6 A% z& r #IfWinActive ahk_class ExploreWClass|CabinetWClass
% `$ ]2 G G4 a# v& m6 \: N. e O ; open ‘cmd’ in the current directory
) g6 k1 [2 l+ g" z ;* x4 y) M! K/ s. x
#c::
& g2 j% P6 a; t' O9 U: D$ n+ N OpenCmdInCurrent()
6 K9 l# [. ]: S return/ m- ^; W* M0 P, L6 r( W
#IfWinActive$ J7 m( f, d8 k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) w: Z( O# n l! \" h8 D& s ; Note: expecting to be run when the active window is Explorer.
8 _) p# J# d0 {- V' }' x ;
; S# m1 M) k2 o" j+ W OpenCmdInCurrent()- w* a+ t* t9 O
{, `8 I6 G" X2 |$ e; M& O
; This is required to get the full path of the file from the address bar
& P! T" e0 W5 v F# D; @0 L WinGetText, full_path, A
. r9 R& O4 J" I/ |* u ; Split on newline (`n)
) ?1 R$ b; T7 W+ A, S StringSplit, word_array, full_path, `n
0 p n& v6 Q' l$ _9 K ; Take the first element from the array. X+ u" O" c: `' A% K$ G, }' A
full_path = %word_array1%( p/ D: ? v1 l* z5 ~
; strip to bare address
! t; j' E+ V8 j& ]9 y full_path := RegExReplace(full_path, “地址: “, “”)- E9 B: \" n0 j/ C. ] M( u
; Just in case – remove all carriage returns (`r)
/ Q! z: h# X9 x5 Y StringReplace, full_path, full_path, `r, , all' S& T4 J2 W' ^& l% ]
IfInString full_path, \8 S; l/ o9 b% s7 m, j! J% L
{3 P+ I9 I, ]) Q# k
Run, cmd /K cd /D “%full_path%”
' n; T; a, j- a4 C) a; _1 d% U }7 t: f8 I5 S/ J" @6 Y
else
+ Q" c Z: D! h {
& X. {8 n) Y, k* A7 c& m1 P Run, cmd /K cd /D “C:\ ”( H2 y* O+ C# M: v( M$ I
}" N# p$ @/ O& y! K$ x& Z; ^
}
0 O3 [. c! ]% I. t2 l4 N) u" O 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: P& }7 I3 h" k! k
这段小代码肯能有两个你需要修改的地方( c" F/ S3 f+ K% S3 l/ N) w
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ p0 w* Y% a! `3 l7 c! L/ ] 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ `) W% i& y2 Q! T5 X4 o! L5 ^ |