此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 u& X$ r6 T2 Z1 y0 `* p
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 ~7 g: b$ V+ }' _% {9 j* i- Z
方式一:2 f" l0 m% M* v0 _ o
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- O: j5 B& g/ u4 J# h! P; e. C 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, e, ^" J8 o) p* J
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 U- F) s7 S% x 方式二:+ D, v# G0 o9 M
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ v# ?' B9 E3 }+ k
SetTitleMatchMode RegEx: B, N+ [( k( G) v- h8 }
return
' R( c8 R& L9 k' `$ c ; Stuff to do when Windows Explorer is open3 e& o! J. M0 s
;
! G7 b5 _7 z) g$ g+ l #IfWinActive ahk_class ExploreWClass|CabinetWClass
, _) P3 b8 t8 K4 J. n) u4 c% P ; open ‘cmd’ in the current directory) ]2 P& o4 X7 a- J ~
;
3 [8 X# X7 r* O% j; Y# t( H1 w #c::5 O: t0 _: A" `% N* H7 i
OpenCmdInCurrent()
! N r, P; w" x1 ^7 G! Q" I0 H return, b; `$ S0 x2 [5 |& y0 h
#IfWinActive, f! L9 t/ K7 G) Z2 J( u- p
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( ]5 o4 t8 X& {4 D/ }+ M ; Note: expecting to be run when the active window is Explorer.
2 \- Y5 q7 h% H& I- _3 M. x" z ;* o) V7 c) P8 u( b
OpenCmdInCurrent()
. y. q( ], z8 L0 q2 n/ G$ E+ o( @& c {2 Z4 H* A) d/ f( K$ ^% M
; This is required to get the full path of the file from the address bar
8 J; q+ }6 m9 ^0 r0 c WinGetText, full_path, A+ j) ?4 c9 ?3 F: l$ W* b
; Split on newline (`n)8 m& I+ E% Q( q' F
StringSplit, word_array, full_path, `n
$ Z; Q- d6 G K0 |8 o, d! c' \ ; Take the first element from the array+ X+ i3 F* d2 \* C: s7 E
full_path = %word_array1%1 v. C1 d! d) S$ R5 M* P/ P
; strip to bare address& v0 |" q; w# o
full_path := RegExReplace(full_path, “地址: “, “”)
; S$ m6 G. a! H! l6 |: y% v ; Just in case – remove all carriage returns (`r): C. y, p D0 x# Y; r) P
StringReplace, full_path, full_path, `r, , all% I2 x9 M* [. s6 m0 E5 g
IfInString full_path, \
: v( z! C# I V7 U6 ] {& K0 g% J9 X+ J" d
Run, cmd /K cd /D “%full_path%”
# b& a2 U& {. C# `. c9 c @- Z4 j }' J3 S U; |3 X+ w* d+ y
else. Q- ]$ q1 a6 ~
{
; C* E# A" e& h3 F; c. B Run, cmd /K cd /D “C:\ ”- c8 q" D q/ U& M( U( t6 i
}
% f$ [) M4 w6 y6 r& I$ N }$ K. a7 e$ l; b. U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& b2 S- F9 c4 h, g 这段小代码肯能有两个你需要修改的地方
2 p+ m1 i5 c3 I) [ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 o- V# ^- I0 i: o3 @% F 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; G. L2 w/ S) `" k |