此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! g' v2 {# ~* N `
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( c. H4 v" [1 z+ f
方式一:
, }0 A; {& n: E# d* O" f# P 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) j9 J4 \ W, g7 ~! y. b4 I7 {+ [. D 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 j% G6 T0 B$ i4 y7 S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 c8 h: h* B5 M) _2 e# u8 h; a" G
方式二:
/ u& L; h9 v# }7 A* y* [0 C 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: i( B3 x5 ?0 Z9 _$ h! {6 [- L
SetTitleMatchMode RegEx5 H& k1 }" F, w6 p- c- n
return% m$ M4 ^: q4 s2 P, \) T
; Stuff to do when Windows Explorer is open" J- J* n$ l* Z' w/ k% q
;
1 K- d- z# U' {2 x8 a7 h7 s# t #IfWinActive ahk_class ExploreWClass|CabinetWClass
1 Z* w1 E# h) l! p" p/ B. D( I ; open ‘cmd’ in the current directory, u( G2 O9 y* c8 k+ h5 a0 P
;
; d7 d- G0 a* U9 i #c::, Q- S9 j' V: A" C) g8 ^ g: w
OpenCmdInCurrent()0 Q$ C U7 c4 t1 ?
return
; _; j2 j* M* ]0 I0 b #IfWinActive
e( h& x9 d" \, T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 h0 r: T3 k" R1 U1 P ; Note: expecting to be run when the active window is Explorer.+ H8 a0 D, P9 S6 j2 Z
;
+ {) p# K7 Q- ?0 {% ]+ K2 f OpenCmdInCurrent()
. P6 D) g9 d: d) K& w0 _ {8 ^3 W4 t3 D& ?' L
; This is required to get the full path of the file from the address bar8 c, f. I" c2 v; ~ W
WinGetText, full_path, A, H: Q; n# j; C. A8 i7 N: w
; Split on newline (`n)& ?1 I: b" e; g, E& O$ k
StringSplit, word_array, full_path, `n0 L! C8 A) X/ @: c2 s: H1 ? c
; Take the first element from the array
7 d4 D$ n( E' q' O- ~9 h. v; U+ L full_path = %word_array1%8 _( s, q4 S" i9 N
; strip to bare address
$ g5 p: i% V1 L" M/ ~2 S( Z full_path := RegExReplace(full_path, “地址: “, “”)! S; I# N! e; D( ~' [$ ^
; Just in case – remove all carriage returns (`r)
) ~7 I, J9 t* w9 s, f$ o StringReplace, full_path, full_path, `r, , all
0 A, |, F! c0 g: ? IfInString full_path, \% S# o3 ?% i- V; ^
{
3 J1 c; k* Q" y; S4 m, Y2 ] Run, cmd /K cd /D “%full_path%”% t) ^' _8 i3 o7 n
} h ~) B7 b) S! w/ U" J( W M
else
* s7 k. K& `0 ~) R& c( h! U {
( _7 V6 v0 K& d' r Run, cmd /K cd /D “C:\ ”
. p2 s a& b& B5 c9 { }
: c1 w8 H- B; ~9 J' [. e" M& w$ O } b+ ?3 e; @8 v2 V
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 D r3 o* O! ]1 F, w* f; N( ^ 这段小代码肯能有两个你需要修改的地方
. d0 e0 r9 _( B3 W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 \- H H" e% v/ F8 h6 p3 n5 _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! C5 F! C1 ?) ]- H4 U# ]4 q
|