此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( d; b! @# w9 S( k$ P% Q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 t1 R& p- r6 G8 E
方式一:+ t" b; c. P4 o# P* P8 Z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 m5 C9 y3 F9 K( T% X: M: r
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 W8 l4 j6 y2 c# y$ m- ] HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 P$ N: T O# g 方式二:( H4 G( T: ]% {$ }$ V) S
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" [3 ?4 [7 z* T SetTitleMatchMode RegEx7 q2 ^6 y7 ]$ v. S0 V5 v0 S. K9 Z: a; Y- l
return
4 J9 k# l0 O% x" U W/ |1 K ; Stuff to do when Windows Explorer is open8 Z$ R0 j7 o( l% F% {0 B
;
) p! Q6 I, F! `3 S* ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass2 N: e& |' J' ]) E- B& W5 N& H1 ^" x
; open ‘cmd’ in the current directory0 ^; A; n7 B$ Q# |) |
;
9 C! ]2 q0 P- y$ w3 O3 l #c::/ @; g+ [- C* @6 J
OpenCmdInCurrent(). x* D: g9 r+ \1 I3 X5 S2 ]
return
( D5 r" d3 \# L9 K7 o9 ?! W #IfWinActive! z l( i8 |1 T* }
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. B# c; ]: W- R1 h7 R
; Note: expecting to be run when the active window is Explorer./ X1 E) Y, }) V7 G Z( e6 ^) D
;
+ }/ v3 U$ w# o; C6 j9 C) ]4 h OpenCmdInCurrent()$ W- ]# _, i- e; m3 m% J
{
8 W& a" `+ y2 ~# N9 M9 V6 a ; This is required to get the full path of the file from the address bar
9 i9 j! W5 B4 p/ o# C: L$ Y, G WinGetText, full_path, A3 B0 L8 a4 c- p7 v: m/ a% U% j
; Split on newline (`n)1 q8 p( r5 Y* w9 w$ ~7 K9 T1 B3 ^
StringSplit, word_array, full_path, `n
/ D( F" Z; @$ ?- I; u U( N4 l ; Take the first element from the array# ?. }8 Z$ {" ~4 X) x
full_path = %word_array1%
% g# r8 p( f3 a ; strip to bare address5 d8 [1 I% h8 u- D1 I0 O
full_path := RegExReplace(full_path, “地址: “, “”)1 t# ^3 F- X$ H+ Q
; Just in case – remove all carriage returns (`r)) D6 |& }/ G3 q' j, a% ~
StringReplace, full_path, full_path, `r, , all4 M. j4 _6 H% R% K
IfInString full_path, \
) r* ^. s4 i- P: X; n; Z {2 g* ?* J+ k T3 D/ B A9 A8 Z& W
Run, cmd /K cd /D “%full_path%”
5 e) h$ |, ], Y }
5 s+ Q0 |# f0 N else- p2 H6 \/ @; D+ j
{& a* |9 z. Y8 m: `3 b+ [9 Q
Run, cmd /K cd /D “C:\ ”
" x8 n* c. L1 _# o5 ~6 f }
- n1 z$ _/ k7 ^) d }: R) Y- U+ I. s. V; A# q; E& d4 D: j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" z9 l, k7 b* Y) X) o: X
这段小代码肯能有两个你需要修改的地方
! l: p2 z5 s3 U: Z0 D5 o" Q/ e 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* `. ]' b' F9 z# i' {# I$ H9 y; s
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: x4 K c7 ^ a* t3 N) A
|