此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 w6 l d% Y, S& K9 M: u" n7 ~ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" E( a& {9 h2 v4 I 方式一:
* e4 Q$ j- v& {) a1 R0 X y+ q% `0 Z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& m# i& P$ J; E! z# t
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
c( c3 |# {' k6 d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; F {$ P; b, v% Q; k' E 方式二:! [4 f1 p" z( e; E' l
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& `/ A: q/ s6 }# w+ o$ E SetTitleMatchMode RegEx
* M0 _, c+ G/ W return
6 q- \4 ?, D6 N, R/ g" ]6 `- H ; Stuff to do when Windows Explorer is open" s3 D# z; l2 \8 m
;
' t% z$ C* c2 X W# H #IfWinActive ahk_class ExploreWClass|CabinetWClass% p+ s: p8 B0 `1 _! r; I3 E- k
; open ‘cmd’ in the current directory( X2 n" ^& {4 R7 M1 s5 J) j
;3 O3 ?8 |& N) ^& J& X
#c::
' l9 r: n7 t" j/ R8 c! p% m OpenCmdInCurrent()
% L" A1 @$ p: \3 Y9 m3 F return6 D0 T( D" e' f2 S9 V
#IfWinActive; u; B* z' B }+ ?, K* W) A
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 T) F+ R- l, l! r
; Note: expecting to be run when the active window is Explorer.0 t2 ?4 H: P3 U% w% v# ~2 w
;* c0 {% G* M S; W3 o+ x: u
OpenCmdInCurrent()
' C6 p; U# k8 H) ~& b* i {
/ x; v8 F1 m0 e4 y5 M4 S ; This is required to get the full path of the file from the address bar' L/ C6 h: X, e# M2 l0 \+ P
WinGetText, full_path, A
& A3 M" r- V$ J* D2 Y( O5 u ; Split on newline (`n)
% f3 D) E, Q6 C% S- S0 ^7 |( S3 O StringSplit, word_array, full_path, `n" E1 ]* ~" y! X4 M+ k$ k; ?
; Take the first element from the array
' Y" t. {9 C) c5 {/ F3 k full_path = %word_array1%
- H9 _7 A; s$ _6 r3 p8 L) } ; strip to bare address
& D; W! |1 n9 N: _# K full_path := RegExReplace(full_path, “地址: “, “”)
( F! | ~ W$ ? u5 I ; Just in case – remove all carriage returns (`r)+ z4 {* o* G: {, E6 }9 W
StringReplace, full_path, full_path, `r, , all
' s9 l9 o4 P. A) }8 H IfInString full_path, \# O7 O! T! C3 f- h. C2 O9 A
{
) _# w5 b1 N0 F$ z0 K, Y Run, cmd /K cd /D “%full_path%”
! O, w. B1 G: i0 M }
6 I- G; T# l& t3 V+ l8 p else
% c0 H% [) y% B- t$ l {0 ~( K8 k0 d+ h# {
Run, cmd /K cd /D “C:\ ”: J, L, J6 T& |, `( Z* K, H- x8 j
}) R; ~6 F8 H% O6 I, j
}
3 `) f% U! Q# u 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 y6 X U0 T/ Z/ I. M
这段小代码肯能有两个你需要修改的地方
6 h% Q- U4 n5 R0 m' U$ ~ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 M8 i1 Y$ e2 _4 O) @, {- x
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
# B: s% }, k' z+ U C. ]2 [ |