此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 x$ G* j4 ?6 t5 o! E& F% C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 o- g H' ~7 L3 M( r R
方式一:' G5 q& O9 v* v
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. E7 U4 H2 S2 Q( ]" K
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 Q$ Y# J) U; W0 u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" s2 S! N: k+ v5 B' {; B6 b2 Y
方式二:
; C+ }2 G' i$ J5 x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 G: L: B, O/ _5 ?; |4 ?* B- \1 V( `( N
SetTitleMatchMode RegEx* v. l J% o) f2 W3 {; ~
return
8 M+ l6 W* N' a$ S ; Stuff to do when Windows Explorer is open* h* @1 h! T" j& R; o* x' ~
;/ l, X: J8 l9 P5 y9 ]2 t- L
#IfWinActive ahk_class ExploreWClass|CabinetWClass
) }0 E A- F4 l0 [ \: r/ h ; open ‘cmd’ in the current directory$ w- h) D; z& d% B7 F
;
+ x( l. ~4 \- t1 p7 Q- F) ^ #c::/ I0 L# F: z+ c# ~
OpenCmdInCurrent()
9 H# c0 A! y9 C- d4 g, z return3 y" z/ r+ F3 _) K+ C9 d& e0 B
#IfWinActive' p5 a+ x$ L v0 l% K4 l6 \
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) L, _ Y0 x( {9 G b+ Y
; Note: expecting to be run when the active window is Explorer.7 T" K6 O9 v1 w# c7 }
;# c3 z5 p( F/ J. t
OpenCmdInCurrent()8 M/ L" ?9 Q4 ^+ W
{0 w* E# t: Z4 I. n6 `7 Z0 l
; This is required to get the full path of the file from the address bar' U3 B i- Y! U' C `7 `0 _; F. x
WinGetText, full_path, A
3 M% x6 s5 l* c ; Split on newline (`n)
& i2 M. p/ L; m8 d' h" d* y8 m StringSplit, word_array, full_path, `n
% e: x6 d+ D, h2 Y3 g) Y ; Take the first element from the array" l4 |- h' e8 y
full_path = %word_array1%
- D& E0 F b6 q5 a$ G3 M/ @ ; strip to bare address
+ X6 T( B2 @$ `- C# ^ full_path := RegExReplace(full_path, “地址: “, “”)# q O4 f: c0 b/ Z" q+ F
; Just in case – remove all carriage returns (`r)7 _% U2 N* k3 I d5 g
StringReplace, full_path, full_path, `r, , all
4 A& Z# q; h: {! m+ U7 C IfInString full_path, \/ \, p5 U9 n5 H+ e0 t5 I- r
{ m1 m' t- t# \
Run, cmd /K cd /D “%full_path%”: J4 f8 m1 L8 Q) I7 {6 W
}, `* f9 I `# n& U# T/ Q' S
else
6 b+ J# Q2 m. B- T3 o2 N {2 A( E8 g" @6 }% | @
Run, cmd /K cd /D “C:\ ”/ f& J- _, N9 [* K4 K
}* V; v8 F7 V- {! a) x$ @- q$ T5 P
}, ?% a" O5 t& y8 i2 f" Q: t+ R
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; e7 s9 G6 J- x+ L9 w
这段小代码肯能有两个你需要修改的地方
" u! D% j! m: o 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 _ c: U( i4 N' s. U, m1 w
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% m$ p, s2 `, G: p% q
|