此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 ^4 i( M2 o% L2 Z' k4 }& Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( o$ z! v" h5 Z( F
方式一:
( x+ ?+ }5 M& e- Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( r* N' C4 x/ ~1 B) y {; c1 Z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 N1 q% h/ O: I9 L/ T. i i, K& ] HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( U; U7 t, t P! j" R8 g; @ 方式二:
0 B' }! @4 [2 n" B 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- x! E% ^# D% K N) s SetTitleMatchMode RegEx0 U2 L# a6 \ a$ {+ p
return
0 R" M$ D2 u$ Q& r/ g+ w. k ; Stuff to do when Windows Explorer is open
$ L! d# K4 g8 N ;
2 b* \2 Y: q* A+ E) z( u" X u #IfWinActive ahk_class ExploreWClass|CabinetWClass
3 W, Q$ D! ~) w! j( M- ^ ; open ‘cmd’ in the current directory2 {3 T% o6 P& d; \# P- ^
;
* _% |7 n* {- j4 |+ _: h6 W #c::
1 j2 X- _1 g/ U! S0 Q+ d0 N OpenCmdInCurrent()' B* X9 p9 d; {0 Z9 j; }
return
! K+ |. ?/ X0 ~3 f8 Z #IfWinActive5 Q) ]( l2 L/ o9 k5 ?
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 t! S2 i% q0 x ; Note: expecting to be run when the active window is Explorer.4 U( _0 m* V, S% b
;
* Q, w. d2 X) a OpenCmdInCurrent(), m7 z/ T" Z( b& o: i( j8 L
{
) A: x- Q/ p& D7 m+ g ; This is required to get the full path of the file from the address bar
1 O2 w" Q- [9 z9 ~$ m- K3 u WinGetText, full_path, A3 A4 E3 W1 N3 M3 m
; Split on newline (`n)4 F# s; v/ Z# ?' V
StringSplit, word_array, full_path, `n" Q/ l8 W+ _3 Y4 T/ n
; Take the first element from the array
% I: R' u# K# M; o$ z0 E full_path = %word_array1%- e2 v+ Z8 x, s* U7 z
; strip to bare address0 a/ B3 ?. e/ a2 e5 \! R0 ]7 \0 |
full_path := RegExReplace(full_path, “地址: “, “”)' N8 y* V, Z# y/ x! V
; Just in case – remove all carriage returns (`r)0 P* i. b4 T$ u+ k
StringReplace, full_path, full_path, `r, , all
7 l1 k( H" ~/ U: i. ^/ d6 Z) Q9 t: F IfInString full_path, \3 m, g! s' {& j. O, C5 w/ n, v
{
/ o. y( P i7 ^! v0 ? Run, cmd /K cd /D “%full_path%”) w1 c& i$ M& |9 I( f
}+ K% q& B+ S9 i1 a9 c2 D; s. C
else) U# i- _( }* ~' a! R
{ H0 V2 r$ t" Y3 v- m- ^* [' ^
Run, cmd /K cd /D “C:\ ”7 C3 r! [7 x; x# P$ G3 r5 i
}9 Q1 W, J* C* f% B! r7 u; Z
}5 {, `: {; j8 G! h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 b% I, Z8 e$ f! p8 u( @
这段小代码肯能有两个你需要修改的地方
! U2 U# e4 P9 B9 z7 Y9 ^" |' P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# q& o5 j! p! \& z' n. l
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" a0 X6 u/ a% h( |9 M5 ?6 D |