此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* g2 C4 u+ b* ? F% g* x6 y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 p6 M) {; ~/ K4 n0 @
方式一:
R6 ]9 P" l6 r1 H) c( q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. d S+ k3 K3 A# f$ Y" R# e; f5 Y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' P @2 n. N# f8 T& M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' r: N+ G' J2 F2 v) x0 f3 E9 B 方式二:& r+ W6 ^1 v- O9 ]; ]
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) k+ j) y% t" J% m" S SetTitleMatchMode RegEx
( @+ q6 H/ m; g9 o5 W) E* \ return/ t- I3 B f: S+ G3 ?- s
; Stuff to do when Windows Explorer is open
* J/ `- `* a! D5 g0 p' k ;1 Z2 s) A7 p8 \; T. [6 ?, [
#IfWinActive ahk_class ExploreWClass|CabinetWClass
# n4 N8 g) P! o: R2 Q7 a2 I ; open ‘cmd’ in the current directory* k; g3 {+ F9 G! z; H7 [; G
;
9 A: x7 _. R0 g' e, ^ #c::
9 } ^' B: {: ]# y OpenCmdInCurrent()
, \+ f6 Y0 I5 k8 ]3 I* x return3 u: X; Q, n, y4 s, h3 l3 S
#IfWinActive/ ~* x3 w$ r/ A. I- @9 o1 l3 O
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% B- E2 C* C# W$ d
; Note: expecting to be run when the active window is Explorer.: ?# L; j" g% ]! C
;" k* j% P5 @: o+ A
OpenCmdInCurrent()
& w0 n( a) r& \ G7 M1 a, j" ` {
/ s- t7 A: I: @; W/ ` N7 S) O0 G/ ? ; This is required to get the full path of the file from the address bar
Z# T8 Z& o& y WinGetText, full_path, A4 M! p' V9 ~" R3 \
; Split on newline (`n)
/ F! N$ Y7 l5 m0 V& U StringSplit, word_array, full_path, `n
+ S4 p4 y8 X m2 W6 ~; E3 U ; Take the first element from the array0 r! |4 j1 _0 i: e% l& e7 g
full_path = %word_array1%$ { g9 E/ G6 G% W, `" E
; strip to bare address
9 ^; X/ G+ g: ^/ f, _3 H full_path := RegExReplace(full_path, “地址: “, “”)
: M0 P/ m R {/ D7 @ ; Just in case – remove all carriage returns (`r)4 ]3 r L9 S& d1 y
StringReplace, full_path, full_path, `r, , all3 J/ X$ y; |- y9 x
IfInString full_path, \" w3 [4 _2 m' u6 @+ k- y5 w
{& m+ l+ y2 }; V$ `( H$ Y) n: @ q8 h
Run, cmd /K cd /D “%full_path%”' d8 D7 T% X" I' h [
}
/ O' h& a) y* M9 n8 z else _5 L, F0 _9 F
{' K0 v K' J. m9 c* Z, ^
Run, cmd /K cd /D “C:\ ”
9 b9 b( e8 Q) ^+ ^0 Q2 Z P) } }5 s$ @; D! g1 i. q
}4 \8 q, s# [0 m! Z: r6 C- D! p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 \6 y# j4 w! m' u) K) S: R' `" Z 这段小代码肯能有两个你需要修改的地方7 H# l) w% A. _- @# r
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 q4 }7 _( o6 G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 B8 h2 P- r+ t; @$ ]* C1 [+ M' ^
|