此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: ?; }/ b' g s7 Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 r1 o) P! |/ y) Y2 _' ^& } 方式一:
: N% [! U w7 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# n; d# M: @5 q4 K6 U3 C1 h4 H: Y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 U" d+ K) v& Q' x6 i# L
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 y& l9 o8 r3 S# u+ d
方式二:+ {0 Y1 R& }1 K' {( s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 B0 b* o' u! z: u, o
SetTitleMatchMode RegEx
( Q1 i9 Y( e% \ return
! u4 O, a/ R' ]4 R ; Stuff to do when Windows Explorer is open
~' X# N+ O, O# [: o ;! e, a; y! O+ e' f/ J! U) H/ t
#IfWinActive ahk_class ExploreWClass|CabinetWClass
9 u$ S' G/ u0 O1 {; x2 E2 M ; open ‘cmd’ in the current directory
6 F+ V6 s7 e' a: _ ;, ^1 S! j" o+ u6 X. \3 U1 X! x8 B
#c::
1 X6 h7 a% }7 G7 x0 l, B8 s OpenCmdInCurrent()
; T0 f: c; ~" \0 q* Q$ [- n M" } return5 \0 j$ y# C1 A' {( a2 S
#IfWinActive
$ S/ M. T) q3 [ m9 c/ } ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 u1 T) V; x& N: F6 g, L( o ; Note: expecting to be run when the active window is Explorer.
0 ?" z. [. H* f/ J9 } ;3 H5 K* {$ y5 a2 X
OpenCmdInCurrent()
" c1 s$ i/ j2 v, R! v2 m {1 u K; t# b4 c( e* L
; This is required to get the full path of the file from the address bar
, j0 q! W. \2 d WinGetText, full_path, A
- p+ X) @) H5 ^1 F, M7 P ; Split on newline (`n)- x& f+ I8 Y% i1 Z5 m6 y5 b% w
StringSplit, word_array, full_path, `n4 I# W! t2 w9 b' I) v1 n
; Take the first element from the array6 o' z+ \6 ~* w4 Z/ C
full_path = %word_array1%
5 b6 r5 X# ^4 d x% h ; strip to bare address# B: A k$ G( k9 r1 y
full_path := RegExReplace(full_path, “地址: “, “”)& Y b3 V0 w3 M3 t2 N l( G% I) H$ f
; Just in case – remove all carriage returns (`r)
8 c1 p% e/ Z2 ?9 J* Y+ |; L StringReplace, full_path, full_path, `r, , all. b/ b* _+ M4 e' D
IfInString full_path, \% S% ?' u! x' x! n5 t
{
1 m: w+ B8 r/ \/ J$ I6 p Run, cmd /K cd /D “%full_path%”
?0 N* V6 u. x: ~% V }# m0 l8 f6 ]( S6 }5 s7 c( K
else, I1 `2 W* Y- ]
{: ^7 J; k, P3 e9 p
Run, cmd /K cd /D “C:\ ”, e( h ^4 p$ u# O
}+ c! q$ S2 L/ B* S
}5 ~& |1 q; D/ o
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 P7 W1 O. c3 }
这段小代码肯能有两个你需要修改的地方! W y2 G1 H! ]3 K# t- I' a: ]% Z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( F. O' v3 I/ |$ z. f' Z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ N9 n- Y. l9 S. W
|