此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: J( p! l. h/ c0 M, N3 z. d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. S a7 F: L' U i0 H 方式一:
7 m7 M, y! j- ^: z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( X& A* v1 w+ D$ a& g9 r
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! G" w! T, @5 T' a9 D HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. v# }! V$ W8 w# P* S
方式二:2 r6 H0 F- K! |4 I/ Q8 E
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' d( D9 P9 i( Q8 g SetTitleMatchMode RegEx
0 J/ u2 s/ c# e3 y$ e& v& U$ K& \ return9 [9 ?: _1 P, \& m; O, d
; Stuff to do when Windows Explorer is open
4 I( V. P, j, }. K2 H ;0 d" v( G& B& t- {! s: a3 O
#IfWinActive ahk_class ExploreWClass|CabinetWClass
?9 r# z) W5 n$ w% D/ Q ; open ‘cmd’ in the current directory
( F! v8 {. i/ J& G' C ;
% q' j7 ?( p* F6 [: V- L1 M W #c::
8 j$ G- v3 R& G# Y2 M; n OpenCmdInCurrent()5 T' T' N. ^/ A: M
return
" e0 U& W3 s i7 A1 L# r! b #IfWinActive- h0 ~0 w+ D# O0 y* p R: @
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 v7 e. ^; c. p f! v ; Note: expecting to be run when the active window is Explorer.
3 c) o5 y8 r& p6 G) b& D/ ?+ F ;/ X( G* j. X/ @8 u& J. l
OpenCmdInCurrent()
( S, b& I! d6 ?9 O8 |" ^+ v: ] {
$ v0 P) h% X" v4 M3 g1 i ; This is required to get the full path of the file from the address bar+ R& G7 f0 Z* ~
WinGetText, full_path, A
0 d( b* Y) Z/ u; c ; Split on newline (`n): a" d6 U# d+ W8 S
StringSplit, word_array, full_path, `n4 K( X A" X. @/ [% {9 W" S8 h# n! s
; Take the first element from the array
: h4 e! C0 J7 Q6 H; v9 V full_path = %word_array1%/ \2 ]/ u- Z0 A2 i; E" i
; strip to bare address. w& h2 E* l' U2 g
full_path := RegExReplace(full_path, “地址: “, “”). m4 X5 e% Y2 u* N0 ^6 Y, f# L
; Just in case – remove all carriage returns (`r)
& R8 p0 Q% ]+ S4 I, d! o StringReplace, full_path, full_path, `r, , all- f, r2 X, g; {3 }" [7 {. A1 C' M
IfInString full_path, \
9 E7 {* l* G/ q% f2 h* { {" S( s) i5 c# f% P9 R
Run, cmd /K cd /D “%full_path%”
8 l) b1 y2 ~0 i; ]5 C$ i }& N1 b/ x; a/ `- m
else
, h+ n- s ?$ t: j) }* ~0 } {
; `! j8 R. S6 i9 a2 N& E& n Run, cmd /K cd /D “C:\ ”6 ?; N/ N9 P' e% v2 |8 F r
}
! j6 f8 L0 Q0 ~ }" J. q" F \8 ?9 k$ c
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 @6 s& J& n t+ M& i 这段小代码肯能有两个你需要修改的地方+ f: f g; ^* |4 s8 l
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 P0 @% ~# T/ Y# p/ l) N) y4 @& j& H" t
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, w/ A7 K' E1 s
|