此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 K" ?+ f& \ z E' G ?
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
% y$ L8 @: b* p8 Z6 |( r( u 方式一:; }5 ]3 g( o3 n$ ^
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- x0 O: @7 B2 c- U, z$ w 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 g$ q; a* J3 D3 @" o1 p HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 s7 H: c* G" @
方式二:/ { |9 s* v/ Z0 Y! H
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! U' P7 i8 p$ j0 U" p SetTitleMatchMode RegEx
, W2 T H0 e7 E5 [ return
7 Y2 [; k( t+ z( P% M ; Stuff to do when Windows Explorer is open
8 ]6 j r5 `* F* _( L5 G# z6 o$ ?. s ;
4 L5 C& F* U# z8 b/ k6 z: \ #IfWinActive ahk_class ExploreWClass|CabinetWClass* @7 N: H" |. N6 J2 E3 m% r
; open ‘cmd’ in the current directory7 c2 F) G$ P$ ^
;
' e" n' q X2 m4 }; `' c #c::) }& X& ^9 x+ G8 F% O' l4 K* ^
OpenCmdInCurrent()6 }! l' l, g- t/ d9 b( Z
return
2 F9 d$ k9 a2 R6 P4 ]4 E4 {% C7 u0 Z #IfWinActive6 U' T: {! i; w
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: d8 i4 c# L4 |* T0 ^ ; Note: expecting to be run when the active window is Explorer. ~& B* ]2 K. u9 C& N9 [, q: e
;$ o5 u3 c- `5 V0 b& b. O( L7 l
OpenCmdInCurrent()1 u8 Z6 z! g. Y8 I# V+ g, B' N
{
& ` l: w0 e6 ]( s: M' S ; This is required to get the full path of the file from the address bar
3 G8 Y2 {( D% a1 p/ m! `" s4 h7 G% [ WinGetText, full_path, A+ r& q: Y! h+ e5 ?, L- S
; Split on newline (`n)
! }( a( X+ _) b( [3 h/ K StringSplit, word_array, full_path, `n
; t0 p" O* Q& h ; Take the first element from the array' F2 A3 E/ A5 R: N4 q
full_path = %word_array1%2 g* O: y. t% [; T
; strip to bare address$ ~! @" F2 i9 t% b8 A# W0 L% s1 O4 @
full_path := RegExReplace(full_path, “地址: “, “”)
! T3 w9 u6 n; W+ [5 `) e! | ; Just in case – remove all carriage returns (`r): M/ K+ q, a5 ^" x6 G
StringReplace, full_path, full_path, `r, , all
: s' ^8 g* m( w0 i. x$ Y IfInString full_path, \
& z1 j; |2 l& e1 |( w {6 W& h! \7 J2 i; B% v: x" T
Run, cmd /K cd /D “%full_path%”/ S1 h4 K) R5 I8 S( ]& U
}, r3 D7 x0 K) W: D. A/ ?, J
else) O0 _* ^7 K2 K
{
6 @0 Q4 H( g0 W2 Q& k# B Run, cmd /K cd /D “C:\ ” E+ t5 |6 T8 m7 \
}0 u& V# m3 x6 u
}- r' }' X/ j* b4 d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) w1 ~$ ?: z2 w$ r! x
这段小代码肯能有两个你需要修改的地方
. C! J5 u( n9 Z% D 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 V8 s6 f5 g; x2 \5 |6 j$ G
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 A* s) Y6 L1 S% L. n
|