此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. M& u r0 l$ \" } 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. S/ a" u5 l f& D5 u
方式一:
" j8 ?* }9 A/ Y; b% s 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* `8 ~& I- _! L; A) K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( i, ?; _, o# Y8 E" i HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- v- i9 G# d4 d3 n2 F
方式二:% X& m, [% W3 F" q1 v
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: b( [, @) q9 U! `" |( V" Z7 x0 m
SetTitleMatchMode RegEx5 {3 C/ i) d# I0 L# q- X
return4 I5 n8 e. K% U8 @+ q5 a
; Stuff to do when Windows Explorer is open
" N' A6 Q+ [3 u! A `3 L" b ;
* S4 \* r6 N9 x #IfWinActive ahk_class ExploreWClass|CabinetWClass
4 [ L6 z0 D+ I ; open ‘cmd’ in the current directory
: i8 Q+ e/ f5 @( w* N ;
9 t( [$ f4 T2 i #c::$ o, y) R9 C: X0 _7 W. P' p
OpenCmdInCurrent()8 T3 G9 K D6 d3 a
return
) l# o6 o$ O# G: f" ~ #IfWinActive# b2 K, g4 p* e- \8 ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ _7 P2 ]5 O; o0 P ]5 s2 h. x7 l ; Note: expecting to be run when the active window is Explorer.
1 p- H8 Z7 l5 `7 s# t- l! e# K) C ;
# f. r, ^) o8 R" u# |& d4 C) O OpenCmdInCurrent()8 B6 ^2 Y1 }: @* s K
{% q0 |4 s- D! Q+ V! ]2 s( V6 E) _3 h
; This is required to get the full path of the file from the address bar' h6 r! d' I- }% h7 |4 ^$ t
WinGetText, full_path, A
2 s# i% w* w; @9 S. `' t/ ^* d ; Split on newline (`n)
) [. n6 B6 f5 t StringSplit, word_array, full_path, `n
# I7 k! d0 q3 Q6 \ ; Take the first element from the array# h* {3 P* H3 j( A/ g
full_path = %word_array1%% z) F. m4 A- j4 C
; strip to bare address
" y8 C: q9 R7 T! v5 X full_path := RegExReplace(full_path, “地址: “, “”)
, a# P k6 B8 }5 b$ ] ; Just in case – remove all carriage returns (`r)
' _. ~, Z5 G4 A' ?( n( a StringReplace, full_path, full_path, `r, , all8 ^, k- x! L$ B5 _. c5 x8 }% f6 L( D
IfInString full_path, \$ U6 m: o: F9 r9 `
{
5 G4 s, f' g s) w Run, cmd /K cd /D “%full_path%”
& [& V/ t0 d1 x$ O2 h$ [2 o }
) w8 _& J4 ?/ q Q! Y else
; | ]7 Y' y! E% e# r R {8 K Y5 r7 ?% M
Run, cmd /K cd /D “C:\ ”
! U3 } D& E( q }% a2 t2 Y7 [$ E" |
}0 k# u7 q3 M7 N0 [7 s5 k
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! S) T, }; D- i5 t5 x
这段小代码肯能有两个你需要修改的地方5 L" x' m% U# f# ?# P
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; G( Q9 v, r# _# V; K1 `3 G5 c% u
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) U3 q+ b6 k5 v$ K8 g
|