此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- R2 g/ g, E! F& ~& H9 F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 z7 c1 ]- T' H: q8 ]; S 方式一:- Q2 B, `- H$ K3 d
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 z7 Q1 ]. {3 A3 H 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ P$ G) ?6 P4 t; S. Z+ f4 g
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 z1 _9 i$ V% N( r f( J1 F$ x 方式二:! e* I% P+ [" L; j- @
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 H1 ]& t& o) Q* ^
SetTitleMatchMode RegEx$ Y! i* g" N3 D. [1 i
return2 t" Q( T- W1 I( b! v7 h* O, l9 h
; Stuff to do when Windows Explorer is open
: N1 ]7 A. A- k& G# W+ i& } ;0 n. ?* p3 p, f
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& Q/ u% O- Z( \' A! V# r' ^ ; open ‘cmd’ in the current directory7 M7 K) L& |7 x) W: z2 E! Y- p
;/ h9 C& u$ h# |$ Z% ~6 ]. [
#c::
* K+ q1 p1 M. n' s: b OpenCmdInCurrent()
$ [9 h8 q: g8 s/ |% D' V return
) t+ }/ ~1 N. C& A5 Y$ e+ P$ t #IfWinActive0 u2 A: }" l3 F! M y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 w l9 N/ v. c ; Note: expecting to be run when the active window is Explorer.
: X# Z) L/ F# G5 [: r3 k: ? ;
/ d+ D$ V8 \. j6 i$ m; S OpenCmdInCurrent()
( ^" d0 v# [' u, b. q {
2 z: A; [% Z& \9 P' k0 g- G ; This is required to get the full path of the file from the address bar" j9 o/ G! y* w3 W' O* r
WinGetText, full_path, A
/ \8 D! o1 Q3 W& }& V' y. p! Y ; Split on newline (`n)
+ I/ f* Z1 _& U, {# q StringSplit, word_array, full_path, `n9 `$ J( b0 {$ F
; Take the first element from the array
$ ^& {2 o9 X4 c7 |( Q f full_path = %word_array1%
# d- Z) g$ {% g) q( e5 g ; strip to bare address( W$ X% J5 c, t j
full_path := RegExReplace(full_path, “地址: “, “”)
0 H% D$ Z% a, y6 j1 U8 |5 l ; Just in case – remove all carriage returns (`r) O. k! ?5 {* H; A9 z6 Y
StringReplace, full_path, full_path, `r, , all- z- j( U e8 U
IfInString full_path, \
, W# k) B, b/ l7 P( b9 ^ {
( S* N: ~4 P& o* `/ U Run, cmd /K cd /D “%full_path%”
' _# F# P9 n) j' ^: u3 Q% f5 P }; P; `; r1 j8 L/ b* q6 ~$ t4 I
else. s* @* T; ~* R3 @
{# w X; q0 s) z) v8 U( c
Run, cmd /K cd /D “C:\ ”! i' G8 D1 _8 U2 A6 u1 E( N4 P* k
}. C: D/ d( p; S! F7 ~9 r9 i& t
} [+ a$ C6 v0 h" P* S
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 z: B) p1 z* Y# Q( G! |0 T) \ 这段小代码肯能有两个你需要修改的地方
5 a9 e- d) ~5 Z4 ~( k4 U; _ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
P9 h4 X4 X1 R( d 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) c- H' q6 I4 k0 U7 G. ? |