此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 F! \! T7 q. _' a g+ s' d 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 D7 t! t- c) L/ u 方式一:* O7 J0 M0 T& h% ?) W! W m$ I8 Z- N X
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ Z( {5 v+ e6 ^# c% Y4 U
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 K2 f& K/ X# r( `: d8 R HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! i+ o- }4 I) b9 e 方式二:
) I' ]+ Q3 H; A; L* }7 y: k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 V% h- T* [3 }9 ~ SetTitleMatchMode RegEx$ o, j' g9 e0 `" H( V$ N+ e
return4 d! Y) L- `5 J# R c, G& w
; Stuff to do when Windows Explorer is open6 r; w c$ U9 _0 s
;) N+ N% K5 h- y0 i- M& I
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ \- B4 p' T) s w ; open ‘cmd’ in the current directory( J( Q g: x0 M; T, V% O
;
+ n2 r' F8 @+ f# B/ {" t #c::
0 A/ P4 k' l3 Z8 q1 G8 L, C OpenCmdInCurrent()" J" D/ X- b/ t: V/ F
return1 I: z4 W8 l: n. y* X6 Z
#IfWinActive
" A, e# K+ b- B) l, |( |+ k, U ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- e' F1 c R, H7 y$ ^2 H, x
; Note: expecting to be run when the active window is Explorer.+ ~. K: z" b$ \0 M7 ]; d
;' L9 S; U5 N- y3 C8 T/ D4 C: L
OpenCmdInCurrent()
% H% ]1 A# g t. {; T {2 V3 J3 e& I, {( J3 `
; This is required to get the full path of the file from the address bar
3 z8 i# G# o+ L! Y/ b WinGetText, full_path, A# ?- k9 E% ?" l8 S [
; Split on newline (`n)
|) N# H1 D3 `- A# W& Z4 }) b StringSplit, word_array, full_path, `n: @% F6 @. {- k$ \! }( X
; Take the first element from the array
7 m' e7 m/ f! a( S full_path = %word_array1%
! D1 `: l: Y% I9 a$ s2 l0 f# x- C ; strip to bare address( K* e/ V7 C* z5 P+ j) Q
full_path := RegExReplace(full_path, “地址: “, “”); N7 ?3 e) v* U+ [: D. S5 L e
; Just in case – remove all carriage returns (`r) m+ Z2 u2 t$ \: ?9 n2 D
StringReplace, full_path, full_path, `r, , all' l- E! i1 X( u" D! M
IfInString full_path, \
3 V+ O* i+ k( l, L {
0 @% M; f* q- X7 P Run, cmd /K cd /D “%full_path%”8 t& h$ d9 t% p0 } I7 {5 M$ {
}) X$ e" q2 ]' ]
else, \- E6 v: k5 T! V9 }* z/ b1 G
{
% O9 K+ P2 y' c5 u& t Run, cmd /K cd /D “C:\ ”. V% P* q5 H9 j5 r B/ o7 D
}
) Z0 k% A$ T t" \ }
8 c, N& D" B: { 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% f7 N; p* V* i2 Y 这段小代码肯能有两个你需要修改的地方3 y; I1 I4 |+ V) r
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, \' Q4 e# Q- q6 q1 Y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& t& D) ]0 c% v {. k) w4 e7 I7 A |