此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 f! o& _; d$ s. a 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! b; w4 T; M1 h+ Y$ u
方式一:
! h+ c: ~& B- I& Y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! \6 Y4 P$ {5 k) y6 T: c1 ~/ n" ~5 I 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, m$ h7 w) s$ D3 e" V# s. q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! ^ u9 g2 P0 g G% v% A" z
方式二:3 b) [' T0 _9 y+ ?8 o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 ~0 _0 t. }4 O) Y/ a
SetTitleMatchMode RegEx
7 A/ q2 V! p) O: G4 ^ return
; i4 x! e3 N# v& K7 d, u4 @ ; Stuff to do when Windows Explorer is open" H, F8 h% U0 k f' f
;
9 I5 o& e7 a$ M8 a# O; x) p* Y- S #IfWinActive ahk_class ExploreWClass|CabinetWClass2 e" k+ k; Y I8 u: C
; open ‘cmd’ in the current directory7 w1 L5 s: E( G& [$ _- F! I
;
: q0 g. `9 ?& m# F #c::
+ a; o0 X! Y) L3 |3 ?! q( \# L OpenCmdInCurrent()5 O, @& Q1 C( I1 y
return1 O0 p. _1 \ [9 o" Q1 {
#IfWinActive$ q# h# ]) g/ v; b* w" Q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# C: p# W# u2 W1 J+ N. k
; Note: expecting to be run when the active window is Explorer.
' W. e' T, f/ j& h: S1 K" g0 u: J' X ;
) n) L1 j3 S, N/ r& N OpenCmdInCurrent()( K3 p+ \/ n* Z
{1 l' b7 V2 l* Q6 q9 o6 ?1 F
; This is required to get the full path of the file from the address bar# @0 D9 }8 K9 q; O5 \; O
WinGetText, full_path, A
, N3 m1 O! L( |2 _+ e ; Split on newline (`n)
, e& `% h- \, G3 \9 ~% z5 ?* G# M StringSplit, word_array, full_path, `n
, z; ?- T9 `2 K5 K. w5 @: g ; Take the first element from the array
$ M9 M( L. @ |& l* D' p% v full_path = %word_array1%
) d! j7 Z& B, w' f7 P ; strip to bare address
; v6 T/ W6 o4 e0 l9 X2 f full_path := RegExReplace(full_path, “地址: “, “”)5 k3 W- T' d, B
; Just in case – remove all carriage returns (`r)
( w& ~& s) W. o# }- t2 c1 a- L7 t) x: N StringReplace, full_path, full_path, `r, , all
" {; H( t o2 e% H IfInString full_path, \
! Q: m- o4 v+ |9 p: m4 H {
1 M4 ` J! O2 V( K Run, cmd /K cd /D “%full_path%”
) c' |6 \. M- z }: C; S8 {) V$ G
else- i; Y; D, @0 v( x% c- K
{
$ I. |/ U3 y/ C F# _6 ~ Run, cmd /K cd /D “C:\ ”, d* {1 ~; o7 f8 o! B9 T
}
9 Q3 E. r( e" T R: `( f { }4 d/ B; l0 Q& p$ w6 x [7 I4 v: o
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 `4 N* C8 C8 Y 这段小代码肯能有两个你需要修改的地方
1 R+ q% B4 z: f; j0 u5 W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 q* |# Z' K% a& m+ c6 h2 | 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. c4 L. ?' y4 P+ [
|