此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ r/ e9 d4 u+ x2 |- H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 Z; N! _- k1 l
方式一:: T: s& `' B- K' m3 R
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* `8 H$ \/ B5 } 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. O9 M, u; d. y5 \2 ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 _ f/ b# h) K1 C 方式二:
4 ?9 Z" K6 w7 A [ `+ }/ S+ i$ v 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 F; N8 \+ y& I( @
SetTitleMatchMode RegEx: e, a% v& N! T- ~$ m& U
return1 \9 z8 o. o: | r
; Stuff to do when Windows Explorer is open3 F# f9 d7 d$ k: `
;- X$ q6 c4 j2 K* O% o0 a
#IfWinActive ahk_class ExploreWClass|CabinetWClass: u; K) s f& Z' `- s
; open ‘cmd’ in the current directory! `6 f3 Q8 |2 n7 k% e0 G
;
& W" x5 C: i0 u2 r: @ #c::2 ?+ d: E' R) C) G2 `
OpenCmdInCurrent()8 @$ Z6 X t% f1 [) _
return Y: `1 e8 C, Q& ~' ~6 K
#IfWinActive
) H2 H4 @5 ?9 B3 R" W2 {/ B# v ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 z/ L7 A$ H" y ; Note: expecting to be run when the active window is Explorer.
8 h0 H; x% @$ I" C# S& X. n ;1 _" | m0 |" Z, ]2 T$ m1 l
OpenCmdInCurrent()3 A% [1 q. ^; z$ t
{5 @: R: X6 w: D
; This is required to get the full path of the file from the address bar$ G* Y$ a1 o0 Z* _
WinGetText, full_path, A
$ C' w. B' m& U4 N. C+ Z ; Split on newline (`n)
6 }9 X: {5 }& ~3 ]+ q: m' v8 i StringSplit, word_array, full_path, `n
' C- n- ^% Y" D( e ; Take the first element from the array
/ L7 Y$ I1 h) o; K full_path = %word_array1%
0 z+ l4 i% q- y$ g6 R ; strip to bare address
% N1 j! L' r8 q3 K# O: u( j0 z: q8 i full_path := RegExReplace(full_path, “地址: “, “”)& o% a4 n8 Z6 @$ ~- D7 r- v$ \
; Just in case – remove all carriage returns (`r)& B: _% k" |# ~9 q, F: y
StringReplace, full_path, full_path, `r, , all
0 T" X# i& G8 `( O7 ` IfInString full_path, \. C% _1 F3 c( K) A0 I
{
) O: N+ L9 o1 N7 F" g$ F Run, cmd /K cd /D “%full_path%”( J: ]2 L( P2 X. L8 C+ I4 n
}& ]7 _1 w5 @. S% Q& Z4 Z
else
# g' F4 m# ~5 ?* _2 p* A- Y {/ z4 y3 Z0 z9 d* E
Run, cmd /K cd /D “C:\ ”+ [) a- ]9 F; M8 k
}
+ C0 ^; {$ M. h" D l" M }. z" X! d; f8 Y) j0 d- x+ `
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! y) g: s! F# P 这段小代码肯能有两个你需要修改的地方
6 F, s3 g$ c& y6 R) _ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ M5 J0 S5 Q& {& {9 O 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 [" O# O( w) \# X( U0 K |