此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 s. v. m6 u+ e& _5 E1 g+ k" {
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* _5 j" g, j; Y$ { 方式一:7 n) y7 w6 E; }% i3 p) d4 r$ O
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 k! J" b* n# U" w K
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! ?, H& U g8 N& I! c; |! {3 C' w) ]+ c0 f HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ L9 n4 C3 b1 q0 u
方式二:
# u3 \6 t2 r% ? N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 K# H* g5 n6 e9 H$ C ^2 v
SetTitleMatchMode RegEx0 h, n" G: ~5 |
return# H9 H+ q2 ^4 q! Y/ r
; Stuff to do when Windows Explorer is open
) u1 B' I$ K! D* z2 _0 P ;
7 G6 z1 f9 W; j7 H/ L #IfWinActive ahk_class ExploreWClass|CabinetWClass
. L% V! c8 b/ t4 a x ; open ‘cmd’ in the current directory: W; `& B$ s T8 P& [
;, o, U3 [7 ], |7 P5 c9 _( v5 [
#c::! r0 E& T1 |2 }# Q- ]( r$ c% K
OpenCmdInCurrent()! j, i- g, ~) F! u
return% _7 X9 i0 R f: I# W
#IfWinActive" p& l% x. z5 g9 Q' k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 V8 J, n% C8 ^2 P$ a* d9 t ; Note: expecting to be run when the active window is Explorer.
% q. F0 T1 H7 E ;1 M1 s& U. Z u2 e
OpenCmdInCurrent()1 O! k' K4 E* U D, W
{
; ~% K* C1 Y& Q1 ] ; This is required to get the full path of the file from the address bar# `- X0 {( t: X
WinGetText, full_path, A- S A. D; d* n: F4 }
; Split on newline (`n)/ s/ e( I0 @7 r; D9 e* R- \! k: f
StringSplit, word_array, full_path, `n; i! h* i& H4 J! S' g; T0 p; @
; Take the first element from the array
J4 K8 E# n8 C/ l; w B full_path = %word_array1%! q3 s7 p$ |9 I) d3 ]
; strip to bare address, E, j0 [" ]7 u$ Y9 S& R
full_path := RegExReplace(full_path, “地址: “, “”)
* C! G$ a! I4 d. F) T( f ; Just in case – remove all carriage returns (`r)/ O# w; O; U& L5 ~1 x" L+ G- n: c. s1 {
StringReplace, full_path, full_path, `r, , all
2 m6 l& j2 ?' D1 \" P0 a IfInString full_path, \/ h' J6 @' P* g0 J4 a% \* G
{: G: x, t7 f& t. M( S0 F/ G! k
Run, cmd /K cd /D “%full_path%”
( W5 ]- s9 w; G% z3 \9 A( Z3 M | } w3 a' a8 a& a
else
. ?: O; _# N0 L3 |/ o {& y8 _) w8 k% N3 H4 D2 D& q
Run, cmd /K cd /D “C:\ ”
2 d7 ]& [3 s+ H }1 B8 i1 U1 u; j/ l9 c; ^
}( w) ^& g2 H3 W# |' m
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( D" d0 s+ ?8 }; M$ t0 L+ C- L0 l
这段小代码肯能有两个你需要修改的地方% L4 m( K! A% P3 g. Q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
l7 s/ A E) L( l: S$ l 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; X6 }6 y5 e( C. X
|