此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) U; _0 t6 P/ d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 Z% ] \. y9 ^' C1 U
方式一:
' p8 {9 C9 d& r0 I2 C 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! l q) L2 t% T, P1 ^3 u 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 v. q+ z* j* G% p( V HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ c1 t( ?! ^5 g6 o+ C 方式二:0 O' |7 s3 L+ m
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 V: d/ m9 a. W8 ^
SetTitleMatchMode RegEx8 X3 r& ~ a( Y9 p2 i( F
return9 o& }% h/ Z/ p: l6 c% n; Q3 _
; Stuff to do when Windows Explorer is open
( T& U# \6 X* J" k! g) c ;/ o) Q& S4 W- a
#IfWinActive ahk_class ExploreWClass|CabinetWClass, K i- v0 R. O! R+ s& k2 z
; open ‘cmd’ in the current directory
. Z, {$ f& e6 Z$ m. l, r ;
' `; ]0 Q' q( v" L #c::7 U2 o: b, m0 q6 {" l" J
OpenCmdInCurrent(), C3 B% V% y8 Z3 I6 b d% h' c5 w
return
8 g; W( X: H. d: @ #IfWinActive/ E9 I5 L7 ]! F9 ` P
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.+ P, L' c( t/ y9 m0 p1 x$ n+ b& F
; Note: expecting to be run when the active window is Explorer.
9 m+ {9 x8 n7 `4 C ;1 w8 I* d( w# w; a, x, w
OpenCmdInCurrent() e+ h% l1 s; r& p' K/ ~6 ?7 n
{8 Z V+ V0 y( [6 |0 q! v$ q
; This is required to get the full path of the file from the address bar% i, f4 G% G7 ?* Q7 X; h* v. k2 G
WinGetText, full_path, A
4 M* b! |+ ^6 A& q ; Split on newline (`n)
; F8 l! N: T( v6 f( i StringSplit, word_array, full_path, `n; M; k1 a F$ K; C a
; Take the first element from the array
9 {, C, a- Q. h( Y full_path = %word_array1%- m- r! |8 A$ h( G1 @
; strip to bare address& |' ? J# H1 r: l* w
full_path := RegExReplace(full_path, “地址: “, “”)! g5 Y! _, k+ k F! X6 v
; Just in case – remove all carriage returns (`r)
0 N( d9 ?0 K& M9 r, Q$ C StringReplace, full_path, full_path, `r, , all
+ i8 O& Y( v6 }( B/ C& G IfInString full_path, \* t1 d5 r3 Q. C# {7 w3 F+ N( _0 g, v
{
; P3 j2 {+ S8 Y# w0 r, @4 c6 F Run, cmd /K cd /D “%full_path%”" J/ e; i, p' e J. c- c* ~: o
}4 f! Z' L( P1 f8 R
else
5 I1 f3 L/ V& f {- Q! b0 V" L, N; I
Run, cmd /K cd /D “C:\ ”
1 u! z1 g; F8 N, t }
9 { k: G7 y/ t }- B3 G1 d1 x3 f9 N+ v
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 t6 e2 b% @# N7 J/ E# c% l% V 这段小代码肯能有两个你需要修改的地方
9 Y' A& q @- a: b8 i7 p! }6 e2 ~: q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) i4 w" q1 r1 _- Q/ v2 Q$ y& m1 C 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" L$ {, v3 e* I
|