此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" C' u# f6 O( l
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 ]) H* q0 R6 d" l) s
方式一:1 n) j2 ^7 m' }' m% ?- a
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
z, i: N2 F Q: @+ P8 C& g7 ~ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, Z5 }8 y# \7 m! \! B HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( d# N# q4 y9 b; w/ o0 ]6 w 方式二:. Z+ j' A# Y( D5 a6 I" `; O8 V
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" V' t9 w) }! w7 G2 @ Y SetTitleMatchMode RegEx: L; B& _2 ?; g" I9 L6 E& w: i
return
5 a |' x! }+ K1 K ; Stuff to do when Windows Explorer is open
' T% I: {# o- L% a ;3 T9 T) ^1 _: M3 v8 W% ?
#IfWinActive ahk_class ExploreWClass|CabinetWClass/ l+ {5 Y# L4 H5 X/ g
; open ‘cmd’ in the current directory) O/ }0 z7 R* P/ y8 g2 k
;3 W3 T, |# Q% X0 d# E
#c::
" w% M# ^- n8 H# q( h* e: t OpenCmdInCurrent()
) e0 q- }4 k! ?, }/ e return
2 u- K2 C. c9 { #IfWinActive
8 K2 j* x: a& B$ m. w6 s8 K. u ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. R* J% Q; `& _! \7 r
; Note: expecting to be run when the active window is Explorer.2 {) y& _, D" n5 g% P$ e
;
: ^* f) P, E1 F# M6 e8 Q5 g) e3 Z OpenCmdInCurrent()+ T+ o7 c+ M/ V$ @4 x0 o8 s6 x
{& O, u* ]& N! {5 X; J0 C
; This is required to get the full path of the file from the address bar
: A. W, o4 C4 @$ N2 U0 `9 s WinGetText, full_path, A$ R3 ~0 t$ x: Y
; Split on newline (`n)3 y% O/ e5 C4 d K9 B% J
StringSplit, word_array, full_path, `n! W2 e9 y7 C! X: p2 e' _. Y7 |& ?) }
; Take the first element from the array5 ^$ s# j7 S1 Y5 `/ A$ Y; k
full_path = %word_array1%
4 B# E( t! t# I; B ; strip to bare address+ n' T1 u- y; ?1 x( q
full_path := RegExReplace(full_path, “地址: “, “”)% }" I: @( o M+ o- n
; Just in case – remove all carriage returns (`r)
1 z# a8 W+ N* T3 C; L9 R4 J& _6 @ StringReplace, full_path, full_path, `r, , all
1 W$ H" W/ }5 m( S" ]+ m! u1 t: n" j, d IfInString full_path, \$ C& a; ~4 D% d# R+ r' d" E
{$ H9 [% I: s! A; @
Run, cmd /K cd /D “%full_path%”# o2 e( r) y; x# W, G( h5 T
}, L6 c* n: J+ k
else
' G5 E8 b/ x* d. ]; z6 { {4 W9 \$ k( Z% p- X0 _$ K6 I' w
Run, cmd /K cd /D “C:\ ”
. |* E6 Y. M. s0 o3 B }
3 H6 |8 }% e6 g$ a2 X2 y }
0 s% w7 H# C8 f) s7 c6 G" C 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) ^ u6 A" W) J4 T 这段小代码肯能有两个你需要修改的地方
7 N" R: x; O+ A: }& Z2 N 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 h$ I4 w" \% a: P: o& m# {# } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( O% |: y0 @$ `. k3 K
|