此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
r0 l* f2 E0 ]7 @8 u 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 r4 k0 z. A% i! d$ s 方式一:
& C0 F. @) A& {8 E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: Z: w. V7 o+ a- I! @ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 B' L; H1 D( k. ^& Z6 W8 B) |! A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ i: c, A3 `. Y3 n4 [( p7 P% L4 v3 v 方式二:8 D4 P ?) b! A9 ]6 K7 ~; }: n- k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 W1 R5 i0 l: Y9 Z+ l6 V SetTitleMatchMode RegEx0 w) K# y' Y7 R! Q7 _1 f1 y
return
; D g5 ?/ G2 Q0 l ; Stuff to do when Windows Explorer is open) W! a! k+ O/ F6 i% P# T8 N2 ?% O
;' B- i2 {# S' _7 T
#IfWinActive ahk_class ExploreWClass|CabinetWClass: j4 i1 ?, Q. J2 L- O
; open ‘cmd’ in the current directory$ `: u/ `: \1 Y% h4 y# |
;
_( s# D$ `+ l4 z #c::
# c/ C9 x1 n- m% S OpenCmdInCurrent()9 u* {" E) i4 k) `3 P8 m" b6 S
return
( ]! K' Z) T$ B; k/ f! A4 K9 a #IfWinActive
9 w% d3 B L- a8 r ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# h3 I- [* N7 w1 E+ b& b6 z ; Note: expecting to be run when the active window is Explorer.% T1 T% m( O, Y
;
) z% @9 t/ ?" D OpenCmdInCurrent()
6 j4 i, \- L& }" F- j" p {5 d! O' L3 r( b* }& D! Z$ G: S
; This is required to get the full path of the file from the address bar1 h. ?9 d# B* Q6 I; @' g8 n( r
WinGetText, full_path, A
& y, s% [; p, Z* N ; Split on newline (`n)( U: D! i9 K) e$ [$ }3 }4 l
StringSplit, word_array, full_path, `n
1 A% I3 l0 Z' l: a- s ; Take the first element from the array; N! E, E! j7 f/ E" Z- }& v
full_path = %word_array1%
" o% _0 g; [! [# N0 u0 | ; strip to bare address, v4 K2 H. U: D/ a: f4 a
full_path := RegExReplace(full_path, “地址: “, “”)
. f7 c( x9 R u. i6 q! T ; Just in case – remove all carriage returns (`r)0 [; I5 w/ a8 M+ {: G* o% [
StringReplace, full_path, full_path, `r, , all
- U0 g. t% U% e- [8 X2 z3 v5 s IfInString full_path, \) f" P& T- P& S. Q s' L. N
{
, ]; s2 G. ]" @3 ] Run, cmd /K cd /D “%full_path%”
* l/ V; z# i- Z5 |7 x }3 S+ P& u" j0 q& G2 a
else0 O# f0 W, [ P3 B6 _
{5 H+ N8 J4 X k+ O/ t7 T' x( x
Run, cmd /K cd /D “C:\ ”9 {3 ]1 t5 I% `7 W9 L, G: O0 }/ R
}
& [2 L% x5 F6 n }2 O: P- @8 {1 C0 @& q. I8 Q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 w( _+ [# T- W& t, e& V
这段小代码肯能有两个你需要修改的地方3 V3 g3 v4 t: ~# h9 \4 M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 b$ E# B9 \- U Q0 q! N3 E A' S
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 k/ f2 p, b% D. O' A5 i+ B |