此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, X6 `! G" h# o9 _2 [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) t; K- ~- K9 v5 A$ F 方式一:
k( }6 D0 d. v/ P) ]- L" v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, P4 W9 C! T1 j' ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# ~ o& ~$ |/ h8 M, G, H' M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 W7 t% W& t# d6 H 方式二: ^' \7 w. Y, v0 |
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" B1 W. H1 u( D. m- z
SetTitleMatchMode RegEx* _; G/ V8 I. h! R3 [
return0 z8 w: S* r' F* S
; Stuff to do when Windows Explorer is open7 N7 }7 `# Z1 [* Y0 T5 N
;
) I" v3 ^; x d# J; P' r" n2 m #IfWinActive ahk_class ExploreWClass|CabinetWClass
' `* g& S# a- X$ F' A/ O ; open ‘cmd’ in the current directory
& d4 m+ S# d) }& X0 {/ N$ X ;/ I0 z3 X8 @" h
#c::0 F! D+ {; v: }! R/ g2 t
OpenCmdInCurrent(). W! ~" K' ^' z3 j" H5 g1 J
return+ f; E/ o: Z- t# @( O/ [. g6 ?
#IfWinActive
% O1 k4 X" ]( f7 u0 K" c$ z5 _ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 t& a, {' L* }% O ; Note: expecting to be run when the active window is Explorer.9 `6 m2 }6 }) f5 V q+ W8 c& A& a# p
;4 E8 P$ l0 E* M' m* w% B
OpenCmdInCurrent(). Z" Q# o5 x) S8 |4 O
{7 |. S' D, [0 E! S6 B3 o) M8 \# ]
; This is required to get the full path of the file from the address bar! [( j- `. v5 o( P8 ~1 ?' B! C4 c
WinGetText, full_path, A
* F9 k G- U. {% a" c8 K ; Split on newline (`n)' m2 q& x+ ~( e, S2 M' F W
StringSplit, word_array, full_path, `n
6 p: x$ V" U2 j! E, E ; Take the first element from the array
- n. T. C9 ~8 X. l# l3 b full_path = %word_array1%" J& T# e. ]" [ s1 K- T2 C
; strip to bare address6 Q+ C; e+ N6 G- O9 @' P% z
full_path := RegExReplace(full_path, “地址: “, “”)
, p' U z9 [! e* M+ V M ; Just in case – remove all carriage returns (`r)
. f/ `1 A/ ` \" P' {/ _ StringReplace, full_path, full_path, `r, , all. Z+ a, J- W9 s+ r
IfInString full_path, \( p: t; H+ w: E5 X$ A( M9 t
{
/ D0 C" v. _3 | x: F6 e( l Run, cmd /K cd /D “%full_path%”
0 ^: ?3 X9 S' b% p/ \# [/ d$ ^: h) D. \ }
2 o7 u5 y& y; B* y! d1 T else8 t* y% D) Q% C. n' D1 x5 O7 y" q
{& i1 J; S6 H/ m( I
Run, cmd /K cd /D “C:\ ”
: }) N" s5 g F( D% P }
( h8 i) e* w6 V3 ?3 p }2 L! {; x! p) A, c g( P
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 m6 S5 A9 S' g9 z" e
这段小代码肯能有两个你需要修改的地方
' [7 f7 c1 r2 g- W/ w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 B& A. r/ a( I+ M$ { 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 X5 B# L- }8 e6 \' Q$ v6 X |