此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 G V) n5 ` G6 f' x" u( ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 T4 r: X6 R4 g# j! {9 Q 方式一:2 c5 [' Q2 l( d- V7 C
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% s5 l: Y( `' l% Z4 k4 v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 _9 f7 n6 P- F! |- J# m* ^
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ ~) j8 d1 k7 i& a; u 方式二:# e d- M3 p; m3 ]( v
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 x! ]# g% }5 q, g
SetTitleMatchMode RegEx
2 H8 I- T6 a5 f# z$ Q" f return% p u9 R; x' B, |6 U1 q% o* D1 Q& V
; Stuff to do when Windows Explorer is open
+ z# }8 C% K) I5 ^0 J4 d5 R ;6 m% I5 R0 E0 \; J* g' Q5 F0 x: j
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 Q/ h% u/ B/ s1 p7 ^) h
; open ‘cmd’ in the current directory
) z3 g# l9 }; W, n: e! v# p ;# A3 C3 s( L J7 J
#c::
( R0 b9 e# @: R' I* @ OpenCmdInCurrent()
5 s* U; Y0 ]2 ]( q' k0 l return7 |0 o0 |+ |& j- p; h3 ^: J
#IfWinActive6 y, d' K" W# J7 P# ~: l
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ {, \% O% i6 b) l ; Note: expecting to be run when the active window is Explorer.
, g( q; ^: j9 X( T- a4 ?, q ;
6 A$ i& _$ ]9 @* H OpenCmdInCurrent()5 H$ b4 z6 D" k! r' M. H
{% _; J$ K8 ^0 q4 ?( a# N
; This is required to get the full path of the file from the address bar
" ?1 y2 q" ]) r; M# n WinGetText, full_path, A
* W8 H8 u! \( M/ F/ c ; Split on newline (`n)+ J' Y1 n; u) K; h
StringSplit, word_array, full_path, `n T. E0 s8 Y- I; N$ Q. X" T! b% s
; Take the first element from the array1 Z: u8 x6 h5 G' ?6 _, ^/ p% p2 e
full_path = %word_array1%* `$ p5 \5 H) D
; strip to bare address
% P& k* F1 h; U0 e& | full_path := RegExReplace(full_path, “地址: “, “”)
$ r; d& ?1 A0 k9 t) G ; Just in case – remove all carriage returns (`r)1 w. z9 B# K: m, w S O
StringReplace, full_path, full_path, `r, , all; J% U" g. c* X5 H
IfInString full_path, \: p- }2 `0 V7 l6 z
{
: y" g' x+ n6 D# e, S; t( L, s Run, cmd /K cd /D “%full_path%”+ B& v! X- p" `* K0 j+ A7 ~
}
8 f) p, m/ r2 h2 m4 P else
0 k- J$ v$ |2 } {" F. |/ |8 ]2 g0 ~( L
Run, cmd /K cd /D “C:\ ”$ z# a+ f" J& e
}
- \. k2 O$ k$ E: F4 n$ l5 V8 V }
6 r* t$ c: l0 ?& V! l6 h0 H" Q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: @ T* ~9 _( s& }/ p7 M( i9 j
这段小代码肯能有两个你需要修改的地方$ l- y0 [5 x( O) Y! ]8 u, H% e
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. e& K0 C- _! c( q' w: X
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. y' v; r" h8 o. F) U% P4 G/ R% \ |