此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# |. Y" a2 `7 w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) ]5 P* O% p: }* y( u5 t4 P
方式一:
. B1 l2 y$ z4 _( `% A' C0 X 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, c& ~1 @. _, R9 ^ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. b+ e( A! z: Y0 i. L k) R% m
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 w) v1 o4 Z5 c& X% t, W, y9 J 方式二:
2 G6 u5 P4 @& f 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 B* E" v% Y3 d1 [# v: }4 ~% [% R
SetTitleMatchMode RegEx
- k! S: @9 a% y' l6 t$ `5 f return. S% P9 k& W. O' ~- B
; Stuff to do when Windows Explorer is open2 i7 |4 ~4 @1 w3 t- H
;, V& v6 i+ r4 W' p9 b
#IfWinActive ahk_class ExploreWClass|CabinetWClass
# X. R5 n' G% A$ p+ g ; open ‘cmd’ in the current directory' {! ^% C) u9 V U0 l
;' I% J. K9 P+ W3 L9 n) q
#c::& D' {' a+ e0 C0 y9 j% _ R; v
OpenCmdInCurrent()( {4 s: \6 `) b, f, O' _% T' s
return! a+ C2 } B; A/ \- F0 H
#IfWinActive6 c1 Q# u8 @/ U' ^1 p. {& j2 t4 v
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: o; x5 W( R. U. Q* _) M
; Note: expecting to be run when the active window is Explorer.6 R) j% E$ P" H0 s% ?! m- f: x2 s
;6 f% z% \# M. }$ U' q5 ~
OpenCmdInCurrent()
/ n+ m$ c# U( M {
8 M8 h& f6 \! u" E/ j% | ; This is required to get the full path of the file from the address bar: }& @8 e2 Z* Y
WinGetText, full_path, A6 f, X! e% W5 W* ?3 W! f( O
; Split on newline (`n)
! k5 V k6 d, u. {' z StringSplit, word_array, full_path, `n
/ F& u$ l* n, \# A7 S ; Take the first element from the array) H! U4 m) C! Q' C4 X
full_path = %word_array1%2 N; j9 |7 \% l) w4 L
; strip to bare address" W( Z0 R& \0 ~9 X
full_path := RegExReplace(full_path, “地址: “, “”)( h& J i3 q$ B; y! q7 o
; Just in case – remove all carriage returns (`r)
8 H* D+ D8 @! P1 X2 S0 J9 C9 P StringReplace, full_path, full_path, `r, , all" k% G, L3 ]0 z% q0 P/ _5 g) Y, q( Y0 F
IfInString full_path, \
# K7 p2 m# s( B0 _- B# L {
, T* | r6 w' t3 _ Run, cmd /K cd /D “%full_path%”& [ e+ K, m# t+ Q4 o5 x: T
}; Z9 Q- x4 R- S5 V- s2 D2 O& e
else
" Q5 z' z+ S. Y; p: I {5 C+ P1 f! M# L ~! `2 s8 M
Run, cmd /K cd /D “C:\ ”( r9 A1 N! [0 Y
}
: d" ^ v; ?; A+ H }" k' s+ U3 H/ L) [- g4 w
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* g, k' K- q9 a: G2 X 这段小代码肯能有两个你需要修改的地方
$ x; W3 ~' {: v0 u, u# O! t' h 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" [4 _6 Z1 O- a' G6 c K! x3 W
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# b' s% y6 X# i' Y3 ^& X" H; f+ X
|