此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 M' F0 \# q; R6 t4 C; k2 d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, M- y7 F1 A: m( y 方式一:
( r/ f6 O- F7 v/ S% x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ ~9 A$ K3 {0 P9 \+ U
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) N( }; l }7 r% E' N$ s
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 E. j2 j( w( A- x6 k
方式二:
2 D5 i, X* w9 r* n 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ y: J# I6 R4 V" M SetTitleMatchMode RegEx
/ r( l" C- F5 \5 D' _" l return3 z0 `& _ Q# q5 B
; Stuff to do when Windows Explorer is open
) L. u. B; T1 ]; N ;
0 }, ], a2 |* R) u4 G #IfWinActive ahk_class ExploreWClass|CabinetWClass/ K" c1 ?6 Q: t& t: m3 m2 s) M! _
; open ‘cmd’ in the current directory+ H" J1 J7 [- c
;- f& X* W+ Q* M1 d9 j
#c::& ^& A' E$ D' d4 B8 q6 |
OpenCmdInCurrent()4 q! @! [4 t; q- e3 i
return
. N- ]$ J X* u #IfWinActive8 G% \6 u G& @9 x9 o
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' g5 H" G& y2 g2 C2 T ; Note: expecting to be run when the active window is Explorer.
. H6 X% G5 s+ x! }/ A1 F& [ ;$ `/ Y! i6 C- ]7 H
OpenCmdInCurrent() a; X- x( A. N2 K. L; H# h
{
/ ^' D9 f& G9 q, [# Z ; This is required to get the full path of the file from the address bar
2 ~' q5 m- Z6 U: ? WinGetText, full_path, A
1 S6 }7 u {) G+ ^6 Y& X) x ; Split on newline (`n); J' m, K# x1 {3 E
StringSplit, word_array, full_path, `n
4 c$ P+ w5 C) X, s6 E ; Take the first element from the array
# C0 d( U5 z7 e4 ^& q full_path = %word_array1%9 ?4 J; [4 Z1 _& O8 P9 E5 ~+ d
; strip to bare address
' D% T! [7 h6 d: R& |% m0 L4 Z full_path := RegExReplace(full_path, “地址: “, “”)$ F6 e* ?6 t) ?2 K& u1 v
; Just in case – remove all carriage returns (`r)" b& {: i( O0 @
StringReplace, full_path, full_path, `r, , all! K5 K$ y& L" {5 _: L; ]1 A
IfInString full_path, \
$ V9 h9 {+ X, l {
" u' l1 a/ s( P- F" Z) X Run, cmd /K cd /D “%full_path%”
2 y8 T: I. f( ^( F" g }7 w2 e" W# B6 U t+ t2 P( l
else M# s* G& j/ Y: }0 `) i
{
& }$ ]4 l5 `% I2 d$ H. F Run, cmd /K cd /D “C:\ ”
k' V% d3 I- o1 h }1 s8 [) W" n/ C4 K4 e! _1 b; Q I/ S
}
. O' Z' Y/ |' u 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& H6 \9 c3 Z! \/ e F
这段小代码肯能有两个你需要修改的地方
) y! O3 D: \1 O9 }6 j 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% j6 Y9 w: S- X, Y0 T! n) c 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ n6 t" ^ E7 j: P1 S& ~/ N( i$ P |