此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' }$ \. C4 O) K. ?4 u, p
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 `. | {3 f% n ?& E" s: n 方式一:8 a% o! A+ \1 N, O1 a
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 J/ D. I' W5 J" S% X 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 X, v* y9 s5 X. n: p7 Z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' n5 K; o3 S: \ 方式二:. k% l, R3 |- Y, m
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& t2 K; Y; g; R SetTitleMatchMode RegEx
, r& d# f* R# g2 P/ V return/ j; H+ Q/ P( E) v9 ], i) ]" \
; Stuff to do when Windows Explorer is open7 i" v; r2 l. A7 W
;) Z+ h2 B4 Q2 P3 ]% J8 _
#IfWinActive ahk_class ExploreWClass|CabinetWClass
! \ a" N6 m( w. J% ?- u) @ ; open ‘cmd’ in the current directory
( ?! |, G5 t/ [" N. V4 _ ;& G2 y3 s% @: T9 a
#c::6 l# `$ m6 L* i( t. G0 I# {+ Z; l; N
OpenCmdInCurrent()
$ ~" C6 [8 D. A0 R1 c return
0 E! y: o0 E# r, u9 d q #IfWinActive
! B" J: t, M% P* V; h8 b ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# l$ ]8 Z9 j1 q) u6 R
; Note: expecting to be run when the active window is Explorer.
& U+ x' j. e! K7 A8 D& L ;
; B4 P$ ?9 ^% T: Q1 r/ A* S; T OpenCmdInCurrent(), a# }3 _, r% S7 N. w+ t
{
$ C8 O" F- D: O0 A- F! }4 r ; This is required to get the full path of the file from the address bar
$ c4 K1 U) D4 D, M' v$ e WinGetText, full_path, A0 x$ j; m8 r _ @" A4 a K
; Split on newline (`n)7 ?* X. d6 d$ _! a% F
StringSplit, word_array, full_path, `n
+ E5 I, E' N7 _; q ; Take the first element from the array
: [. A7 D) t4 |: N+ E/ [! p full_path = %word_array1%+ b1 p O6 I3 o. \; B8 G1 P1 _
; strip to bare address- z1 S& ~% N. t, W
full_path := RegExReplace(full_path, “地址: “, “”)7 M7 F, e) b: \
; Just in case – remove all carriage returns (`r)
- q! V; D9 ? D! q0 f; Y$ s- s StringReplace, full_path, full_path, `r, , all
2 ^6 C1 O- u5 [ IfInString full_path, \0 V9 I" V% ?3 \3 }. @
{
% u8 g `( Z, u/ e- e Run, cmd /K cd /D “%full_path%”5 Z7 R2 u; r5 X$ R/ _, r
}
7 L8 c8 n1 m8 J7 b' s9 M4 |$ `- v else
0 U3 s: Z( Q' `6 q. ^) g {
8 C% I3 t4 r8 }: N" t* }1 ]4 I Run, cmd /K cd /D “C:\ ”% `; K. t0 z- E+ ^
}
3 z5 P i2 t8 D: O( H- U7 _ }
8 l: v* D8 H0 \ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" N: B _3 k( t3 v M( k
这段小代码肯能有两个你需要修改的地方4 W0 P5 P, R* d: V6 m# r
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# B8 C$ m3 i' A, I0 ^, |6 ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; e; k- C! l V5 t _3 I/ ], Q |