此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, {. s% K2 \9 b9 X 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
7 `3 k2 ^. t$ g8 k" n& v 方式一:; T6 M2 `1 f( k4 w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; r0 t+ I3 b7 H3 _0 G% P4 p2 Z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ b, O/ o1 ]5 F8 N0 g HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 ]& \; d9 @) d2 d! B% V' d$ {+ h Y 方式二:
6 M" L7 k" g& T- w1 h 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 ?: [, Z" U# M+ ?" N* w. U4 k( O# P
SetTitleMatchMode RegEx
* f8 d" c5 J' q0 c5 [& y9 r; N5 D return, V3 O1 _, c b- p
; Stuff to do when Windows Explorer is open
+ |# O5 ?' a* X( e" ]! n% I d ;- K3 I" K- J7 G' d p: k+ g
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ \& }5 o' I$ f7 |* z ; open ‘cmd’ in the current directory
- D& t0 P7 v1 C4 r; B ;5 i9 |; L& G8 `0 p M9 u; _0 ~
#c::
# ^& o j+ i3 ` q OpenCmdInCurrent()
7 J! A3 B' i( q Z5 F' Y return
$ Z$ y5 ?& Q- c& B% L, O+ _- g #IfWinActive, o- G7 g$ B! i$ C+ Y4 ~) R5 [/ b" M
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ @+ c: V: U, z Q+ y( O ; Note: expecting to be run when the active window is Explorer.9 }4 ^0 h2 A2 `/ C& i3 b0 M
;/ d G6 J* i& p: @* ~
OpenCmdInCurrent()/ ~7 h& J4 V1 ~7 j+ N) E8 F& q" l
{
2 {# ~7 k" v6 ?1 V9 s5 T ; This is required to get the full path of the file from the address bar! s6 x+ d7 l0 A4 g, u# }
WinGetText, full_path, A
# E; p/ A/ h- B2 K ; Split on newline (`n)
# J, C2 j2 w" ?* T Y StringSplit, word_array, full_path, `n+ Z, d8 t" S, O: |" v
; Take the first element from the array( z" D4 m( C5 [/ u& R# K$ G$ S, [
full_path = %word_array1%' x) @' D8 a* q& f
; strip to bare address
6 X2 A: L' ` l7 y" S6 N8 C full_path := RegExReplace(full_path, “地址: “, “”)
% z; {/ ~( q5 ?0 w6 m+ L4 P$ n ; Just in case – remove all carriage returns (`r)+ ]* s" @5 m8 G( n6 B& V
StringReplace, full_path, full_path, `r, , all( s/ p" \8 o- Q5 E) D( ]* e
IfInString full_path, \2 w; c; O9 v( c, |1 y) Y5 X
{7 e* a7 {( v" m2 B1 D
Run, cmd /K cd /D “%full_path%”
2 M: v ~ E( O5 W) v }; G s" t8 _- s' H* v! f7 b, A) P
else( z% J% d+ r% o0 u4 p* Z5 w/ A) _
{4 i- ~$ b2 Q8 D, _4 _. e
Run, cmd /K cd /D “C:\ ”
( t z3 B2 b9 ]( x) g+ c) T D' d1 W }% A: C/ c8 e7 I5 ~! o. v
}: p3 p2 ]8 U) J6 L( P& q0 I
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 _0 t* T4 ~, t1 [! m B
这段小代码肯能有两个你需要修改的地方3 x" E" Z) t( [' m& X3 |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ i4 B" M e! W6 P% u6 B
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: F$ J8 F4 K! S. D: [ o: a
|