此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 J, k. F2 q5 T! a" Z4 t. ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 ?2 e# |. t7 _3 o, w+ W1 t2 a
方式一:
* M2 u2 w D8 f. S 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 }- n. q9 W- O# T; { 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# u5 d- ]4 P" I( {7 q8 E$ U HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) }, ~1 ^' p0 Q/ r
方式二:
* k' z& o }( M3 w+ } 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% r) j- o8 K" g( `! f1 C
SetTitleMatchMode RegEx2 B9 T( c; e' B, H$ c3 Z0 i
return" b4 L9 [) ]3 w0 r% ]8 H. [
; Stuff to do when Windows Explorer is open
4 O, D/ b7 x0 b& ~* V: E: G ;( E* l7 i* x& Q% v. X. r1 Q; ^6 T9 ~
#IfWinActive ahk_class ExploreWClass|CabinetWClass
9 n' v: W% B, c7 g ; open ‘cmd’ in the current directory
, G7 S A8 t' i6 V* O8 Z5 }# z ;
) H! M; b* A6 C, _8 k. f' p9 B #c::1 X4 j& P9 y6 o c
OpenCmdInCurrent()7 g/ O1 S* O5 @9 B2 Q' Q1 D
return
0 `3 V% y( B E. T! P #IfWinActive
5 Y' _. t1 a7 I9 g8 d) J ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 _1 ^4 @9 i2 F2 H8 w& G$ c% c. } ; Note: expecting to be run when the active window is Explorer.
4 g$ A; }: }( F* J. w: @ ;8 }* M, {- k' O7 h6 S
OpenCmdInCurrent()* ^ `2 B ]3 }5 ?$ i0 z/ {7 C
{
, n4 [( }0 ?- O0 k( B# r* @4 s ; This is required to get the full path of the file from the address bar5 Y f/ R% e$ d' r6 \
WinGetText, full_path, A
( j" o1 {! X% i/ T* a& \ ; Split on newline (`n)
" a3 ]2 s. U- o& k4 u( U StringSplit, word_array, full_path, `n
1 P2 G& q2 K- I9 @* x3 t ; Take the first element from the array% X2 h: `1 d+ b5 Z7 n- M
full_path = %word_array1%
" V8 x9 i" S* l( @ ; strip to bare address
, V* K; w. N$ z+ | x; k full_path := RegExReplace(full_path, “地址: “, “”)
; e2 `, s# v' e ; Just in case – remove all carriage returns (`r)4 N5 e6 \6 m1 t! G
StringReplace, full_path, full_path, `r, , all
- t: \5 d! u# ^ IfInString full_path, \( H0 F2 m4 }7 m6 k' x u, p
{5 k W: ~' C0 `' X3 W; ]
Run, cmd /K cd /D “%full_path%”4 i/ F! `( t6 w- J
}
* e! Y0 R4 x% y else
" b1 f& ^8 |6 ?3 @! f2 H0 |( p4 Z {/ X6 ?5 A) b* Y2 c7 t8 h- p% X
Run, cmd /K cd /D “C:\ ”
3 W3 A% J. ~5 e/ `( m( y }0 U. R! q: {8 D7 u
}
9 X6 ~* Z7 B% X$ g& ]4 L7 W 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ A1 g8 k( v# O" o 这段小代码肯能有两个你需要修改的地方- H/ i2 O0 j% Z7 ^1 I! u: v
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 i1 I- {7 `3 f8 h p
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% q+ b* F1 o5 V
|