此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; c# p7 p7 i9 b! R3 P' d 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 x# Y# l: k7 ~. Q' L' |
方式一:
( a; e+ r& ]2 M4 V# V" a5 ~( f8 y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 _7 y. i. c3 d4 j$ @& G$ g 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% n o0 P$ S. p
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ n5 [9 |, y- r( O j3 b 方式二:
, n& T; |! U" E: V$ C5 L$ B# l 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 H8 D4 ?$ d* K8 t SetTitleMatchMode RegEx
, W1 k( i& c+ g, u: a return/ @' I' j i4 `' n1 Z
; Stuff to do when Windows Explorer is open
3 v) B9 ^) |: U8 V6 e& L ;3 }8 | o2 R }$ M( v9 w% b
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 p& j% M4 E" ^! |2 Z9 |8 P ; open ‘cmd’ in the current directory9 T$ V# \1 a8 q2 G4 ^/ q
;& k" I' I0 X- ?8 H+ X5 t! {- P# t4 e
#c::9 h+ B' T# T* }4 c9 g1 q
OpenCmdInCurrent()! X6 T- U/ E# A9 G( N& C4 b
return5 p2 _$ W; q# G
#IfWinActive: a7 O5 n, { T) P5 x% `
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 x; ]* R: `- b& J; X A ; Note: expecting to be run when the active window is Explorer.1 ~1 P2 m) k; J& S/ C k& G6 R
;
! ~7 i- s9 k+ F; N+ \. U OpenCmdInCurrent()$ C4 |+ d, k! \, c
{
( A$ i; @( p9 i! y1 x4 n2 K1 @ ; This is required to get the full path of the file from the address bar
3 e* V# u# E P6 T WinGetText, full_path, A# \9 W0 q/ l) \4 |3 s
; Split on newline (`n)
9 O0 G3 V" _7 Q" ]3 [ StringSplit, word_array, full_path, `n
; D, }! \: ]4 ~! s O5 I7 h% K) ?/ g ; Take the first element from the array& K) z% s5 a, Q. r0 [; q
full_path = %word_array1%* ^' h; z; L; v' e- j
; strip to bare address
; i- Y9 K, `( X% } full_path := RegExReplace(full_path, “地址: “, “”)
5 u% A N5 p( U+ ^' M ; Just in case – remove all carriage returns (`r) [/ u; ]. _/ I9 B
StringReplace, full_path, full_path, `r, , all5 d/ p) |- K* r f' A$ D
IfInString full_path, \" G6 B: Y3 Q2 s6 a' Y
{6 }( ^6 h: u, T4 P4 r
Run, cmd /K cd /D “%full_path%”
4 V+ `1 J6 m R }: q. H3 p( g0 \8 E6 F: k w1 l Y
else: b1 {. C; y: B) L; h0 G& p a
{9 l6 \8 E7 D$ F7 A
Run, cmd /K cd /D “C:\ ”/ N5 L1 u' h) i3 h9 J
}
$ b4 P3 J) @3 |3 b# n }1 v9 }: E7 ?! r, e6 n2 N( j7 K
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; ^, w9 ^) Z8 a5 V
这段小代码肯能有两个你需要修改的地方
+ W8 L$ P9 E7 y. k$ k 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) W, J* u% T+ w/ A7 T
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: C, Z4 n8 a" \; h8 x. m2 t |