此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 W$ k2 w2 k) ~( I5 D6 e9 T
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. m6 o- q8 T2 t, s% [
方式一:4 j% Y. T9 o a! S) k) ~/ f
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) s9 B/ j G1 F 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ h w2 s; A* Z4 Y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" \( g6 x; v! D
方式二:
9 P& r* n' a( W1 W, Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" E9 H1 y8 X% S) C% c: |5 m
SetTitleMatchMode RegEx6 C3 d2 O& x5 C; {
return
2 G5 o+ A8 L8 K% y4 y ; Stuff to do when Windows Explorer is open
; `6 d: q$ D. q8 X ;# g8 e% o- J+ j
#IfWinActive ahk_class ExploreWClass|CabinetWClass- x) [" }& N% @1 e
; open ‘cmd’ in the current directory
; N2 c" i$ v7 L1 O B% n7 N& @ ;
/ q8 ^7 o5 I% Y4 p, _ #c::
) Y+ [* k% \; N) d6 \% P OpenCmdInCurrent()( ]5 i" G6 S, H
return
% i( g( [* T" t0 d6 G' j #IfWinActive$ ^8 \! U/ P! j) w+ S" i
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 k4 \9 k) z8 N* C1 [ ; Note: expecting to be run when the active window is Explorer.* A3 ]) `: {/ b& l8 G+ ?+ F6 X
;
5 m: ?) D/ s, a: _8 F& u/ O6 k" f OpenCmdInCurrent()/ O% J% j; T& e, G1 V
{" f& x: I! h5 P6 x' Q/ j
; This is required to get the full path of the file from the address bar4 I: M. }2 S4 o1 Q3 o7 p4 S) L
WinGetText, full_path, A1 r3 G+ D2 w# v& L. y- N- D( Q$ I
; Split on newline (`n)6 }1 f7 X7 W0 [5 C+ Q: _( V' s7 f/ i
StringSplit, word_array, full_path, `n: R4 \4 `% `5 x
; Take the first element from the array
9 O+ `& O+ ~3 ?$ K full_path = %word_array1%
: v+ I9 ?/ H% k ; strip to bare address
7 H* q) \8 A' `. |6 F+ P full_path := RegExReplace(full_path, “地址: “, “”)
4 u' z" i" ~" n; x% K ^ ; Just in case – remove all carriage returns (`r)
; p# p2 N) P; y+ z. t. G* E5 u StringReplace, full_path, full_path, `r, , all
1 @/ K2 R. G4 _4 B* ] IfInString full_path, \
( ~4 l# D: m" P {
( V) d6 w. b" Y0 O0 v Run, cmd /K cd /D “%full_path%”
/ C7 U! a" p! o }0 }4 B y4 w! n% r6 Q% A0 g
else
3 D; O* y- Z: u. S$ H { o. X2 n0 _: H
Run, cmd /K cd /D “C:\ ”
( P- W3 [- M9 n1 h }- N8 @) D m; Z; s
}
: f: F$ f* y) \% q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- D7 G u P' Q4 F5 J1 y3 ^ 这段小代码肯能有两个你需要修改的地方: h3 i! e. H! v8 e3 E( e
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! {8 }5 A) a: j8 P* d! I; o 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% a K% j. J4 ^+ d |