此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, k4 Y$ F/ I1 p! x0 z( K' f
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ Q: v& X o# l, {: ~
方式一:" h% R9 k. V1 q% b
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, s+ V/ H4 ^' N. `! d' _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* E7 N2 @8 r; s% [# b Y+ _1 M b. w) k HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% p( Z3 x$ d5 ]) ^) n W8 _ 方式二:( a, r% v4 m9 a6 a+ n8 n) W+ F
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- n' S( x" o- |& Y% p7 a. V SetTitleMatchMode RegEx
% d* ?& F8 s; b return
2 j2 K% F! a1 `4 \ ; Stuff to do when Windows Explorer is open4 B% t6 q9 m# P3 D6 r
;
5 u8 X# ]" ?* O" L3 n #IfWinActive ahk_class ExploreWClass|CabinetWClass/ x: e$ T7 @8 G( @
; open ‘cmd’ in the current directory; g* O8 H5 Y. \6 a3 N; _! B
;3 Y! h+ L9 N; x4 ^, @
#c::
1 P2 l) P9 N% o, l, T% q* ^1 X+ | OpenCmdInCurrent()
3 s6 S4 u/ L, C7 \$ b' p4 { K. D7 q return
2 L& _7 I" N! y #IfWinActive
/ w; n' W7 i5 m$ C) F/ s ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 n5 B0 y @5 D3 L2 V4 T3 C
; Note: expecting to be run when the active window is Explorer.9 b k' }- z9 t
;
5 f, o6 |# l. L- I9 C OpenCmdInCurrent()
1 G, z( t7 C: B5 A! F! a% S {# V! B, B2 @8 B! s% [& j
; This is required to get the full path of the file from the address bar
( D+ k. N; Y6 g! X7 I; Q- |) W; E WinGetText, full_path, A
8 D1 L z! {( E8 @ ; Split on newline (`n)
; z# X4 s( F' r2 v8 V StringSplit, word_array, full_path, `n. v ^+ |: m7 F
; Take the first element from the array0 ^/ D! n% I7 j( Q, j8 @
full_path = %word_array1%0 o# M" V. W1 I+ ^! u3 S
; strip to bare address
+ h: o8 `2 ]7 s" u. J, ?7 ` full_path := RegExReplace(full_path, “地址: “, “”)' E0 e: P9 j$ W
; Just in case – remove all carriage returns (`r)- N' o; G4 n1 k3 C/ e
StringReplace, full_path, full_path, `r, , all. t- V$ P7 R, K3 f& |3 l+ K
IfInString full_path, \7 b6 C) K4 ?. H, ~
{
, b+ S6 W# `6 P- Y# ? Run, cmd /K cd /D “%full_path%”
' j q0 B5 ]9 L7 w5 A; |5 F' h }5 G8 B! Z9 s2 i
else. t8 |1 h: @+ m$ s# M# X
{# P. s* Q' F7 r0 {2 v
Run, cmd /K cd /D “C:\ ”' K7 x! k; H, k' {: O+ V
}
9 T9 ?7 C- d4 {$ Q1 M c; u }
) N0 V- a2 ?4 N" @/ m* e( m4 n 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" t- E5 y. j0 |* A: {$ R# X( x( l
这段小代码肯能有两个你需要修改的地方6 }$ P- R6 S( C& ]8 y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 Y6 ], q: L0 Z- @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: c. Q# ~( r, N* j( P+ O" |% M
|