此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* t% J4 M, X2 x, T 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 U6 V2 c4 N) l E+ `1 B% N& M
方式一:7 n; J& `9 C( I9 p" o- R4 ~. s
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ r3 x7 {4 l) y1 x7 `: l! S6 F 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& P3 w; z/ K) f; @# ]0 o3 q* z. |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
{4 i. D( P- b/ @& f 方式二:! R. R1 ~, x- }7 I7 }0 D+ z2 i
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( g9 W$ w/ h' \' x1 @ SetTitleMatchMode RegEx
4 P2 S& c, q7 j* a; E& G return
) F& N O1 C( @- \: _* Q ; Stuff to do when Windows Explorer is open L% ^) L. U# ]: M
;
/ |) @& {' H0 K6 p #IfWinActive ahk_class ExploreWClass|CabinetWClass* C7 L& ]: b) U& N' S
; open ‘cmd’ in the current directory% o; `- V2 @3 ?; S, ~7 a+ F" I
;
0 ~! H" _1 @2 x: D& d! @% P #c::) c3 ~7 D" @4 B* o9 e
OpenCmdInCurrent()
3 b1 L- [8 `/ {. g& t3 P1 n, L8 O3 _ return
3 U+ l) s7 o# {& \ n #IfWinActive
2 M% N E7 A# Z1 u ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# E* k) i7 r1 B- S- C
; Note: expecting to be run when the active window is Explorer.. K6 X3 o) g* Y& n' a, w2 F
;# U$ V: z2 t. T
OpenCmdInCurrent(), v/ p% |( o e, U' _) G, H3 A% }
{
9 Z5 T; A$ U1 G/ @! @ ; This is required to get the full path of the file from the address bar% t: Z' B# \- o& V8 w1 N4 S/ ^
WinGetText, full_path, A D3 m- w" X3 l% W6 G* \
; Split on newline (`n)
. z, m& A1 I6 p, }5 W StringSplit, word_array, full_path, `n3 f8 l3 c. W7 e/ v
; Take the first element from the array
5 i, G7 m# y2 @/ E8 l- j& ?8 F full_path = %word_array1%
) y2 N+ ]5 F" w ; strip to bare address
& f6 }& L8 N( K# V/ H" O full_path := RegExReplace(full_path, “地址: “, “”)
/ V! r* r# T8 I0 ~8 x6 { ; Just in case – remove all carriage returns (`r)
4 @' K3 e) g* {; P StringReplace, full_path, full_path, `r, , all" j; I0 m5 R$ F9 t$ k/ ~, q
IfInString full_path, \+ r) L! o' l$ E% ~( U7 ~
{) E7 Z. Q3 \0 d3 r$ m/ k5 R
Run, cmd /K cd /D “%full_path%”- @' S( A+ _* \2 e. b& N9 L" n; O4 O) @& S
}
3 `/ x3 `# I- S: j% T T# k9 d else
, `( i% R- F0 L {3 G1 l8 T- o# X O$ | S
Run, cmd /K cd /D “C:\ ”( j. Q$ h+ d; w/ ^# N
}3 k" ~. G C0 B; O# H
}, S6 r2 R& B- v& K
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 ?6 d/ o1 X" _& _' b 这段小代码肯能有两个你需要修改的地方
( z. x% w2 z: \$ l- C 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% ]- `) `: Y5 Y2 u" Q' v 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) }" V! e2 a9 B9 H |