此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
r8 s. B. |$ O+ I) d+ D& i; Q* M 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
% B/ T6 Q, h; ~$ q9 B' t 方式一:
- g6 k$ [0 K5 N! U 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 T2 x( H6 M7 Z9 J& Z5 p& ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" ?7 Y' i6 ^& C, z: M6 T4 |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 u* W- V; Y% @! v2 ]5 ]( {' |5 O: t
方式二:
2 \' k+ g5 E: y. n% o( V6 b0 _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 _7 d' u5 `, k8 X$ W# c$ m7 q
SetTitleMatchMode RegEx* O4 V+ I2 `2 Q0 J" w2 s5 e% B( z
return" u, S% h: {2 T) c0 P, P, X
; Stuff to do when Windows Explorer is open. f, X" y" F' j4 K; T( ]% H# L
;" Z, M% O- ~- V$ h5 l8 J8 b
#IfWinActive ahk_class ExploreWClass|CabinetWClass
* _( {& W, u* n) z3 s4 R; ? ; open ‘cmd’ in the current directory9 Q8 Y' f. ]& N. s) x5 t0 v% o
;
& X( p7 Z3 |) Q4 ]; e. c! ]8 ` #c::- a" i% @; H6 d4 ]: X. e
OpenCmdInCurrent()( u' Y; ^8 l' V; \6 ]
return
* A8 W& L* o9 \- s# q #IfWinActive% C, Y" O* F% j3 X9 k2 `
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: @+ L7 I: v2 t' E& v! c ; Note: expecting to be run when the active window is Explorer.2 [7 F; a; s- m- ~
;
; o/ U# M" p8 b) C) C OpenCmdInCurrent()
3 c' m' P: f L! b! K {0 T+ x" M3 }- G: r) |1 S$ Z: x/ }( X
; This is required to get the full path of the file from the address bar- e& b) X5 z7 {8 P, S+ f. j
WinGetText, full_path, A
, q' H! ~# k/ Z. c5 x ; Split on newline (`n)
4 ?4 L/ Z2 R- w9 V0 r2 }. Q StringSplit, word_array, full_path, `n
: {4 T& L# a4 X ; Take the first element from the array0 V* _! L' A+ j, U$ P7 p
full_path = %word_array1%
. H6 H: p7 c7 I# N! {5 I ; strip to bare address
4 X3 E5 R( d1 `: H" a full_path := RegExReplace(full_path, “地址: “, “”)
- Y% {# K e. _3 w( z6 r7 p w ; Just in case – remove all carriage returns (`r)& O( F8 H* r6 L$ i% z, k9 q3 o# Y
StringReplace, full_path, full_path, `r, , all/ f6 U# ?4 Z- ?+ d e& |0 O5 J9 i, e
IfInString full_path, \
! S: I- T/ e6 T- n {; k! P3 q7 h0 N0 u% T- d
Run, cmd /K cd /D “%full_path%”0 {" V1 t, ?& ?% e; T3 A2 m( h
}
; t( u3 Q1 X, D; }* Z7 x9 h else
6 F2 ?) Y6 l3 A1 s1 P; ? {; j% t1 A( j% _; G/ X4 w
Run, cmd /K cd /D “C:\ ”
+ \! k4 g1 a0 Q }
9 |) n: P# }3 u2 @$ b9 y }
% R; u; w+ U% ~/ f" e 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 W2 S- I4 q- z) u6 S( d& V9 ?; |" x
这段小代码肯能有两个你需要修改的地方
2 N5 E' q* ^8 f1 m 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 |( ~# J( [0 M* r& h6 B3 {( m 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. @4 u4 D4 W! u1 e5 U# I8 O: W" N
|