此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( o8 n5 j0 [% ^: @, t R' g% L 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 K5 \. f+ w7 T3 i6 ]' s8 O) C+ O 方式一:
# F( B$ o4 m/ |7 d0 d" p# R 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 j: f2 a6 J7 Z( h& ]) J6 F) ^3 Z3 p( N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& f* }" u5 Q1 ` Q( s" X1 J HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# o" G* ^) m$ K# k3 o: P 方式二:
; D5 l @% y; Q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% Q3 B$ `- Q z$ ~ SetTitleMatchMode RegEx& e! t" S0 W; A' L4 K; M6 A9 |
return
5 d; R* x( Q/ ]6 C ; Stuff to do when Windows Explorer is open- B0 Z5 U% W3 |) q
;
+ p; S- Y+ n6 J: K2 ` #IfWinActive ahk_class ExploreWClass|CabinetWClass
! H# ]( @+ x% B- J5 w! ^ ; open ‘cmd’ in the current directory$ ^$ Y. w% p( \7 f" a
;
9 q# t1 r/ e+ V: p j* _. q #c::
) w3 [) w" d/ _) D3 v+ Z) s& ~" {; f OpenCmdInCurrent()
" Z" l u, F" x- }2 c return
' i8 {, T* l3 t" T #IfWinActive1 T9 Z, a/ R9 ]) V
; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ `, u* w# U4 E0 R0 a
; Note: expecting to be run when the active window is Explorer.
8 H1 y6 n, b5 Y+ S1 Y ;" K1 D7 M5 V3 _5 N( P4 Y. ?
OpenCmdInCurrent()
" r! C/ e- C/ E) |8 ^% O" ~6 h {* d9 B/ |) j( ~: J1 Y* x$ ^
; This is required to get the full path of the file from the address bar
6 }. M& W& |4 R+ E. N) Y; l WinGetText, full_path, A
$ Z( R. ]& ?' M8 O) ?5 J ; Split on newline (`n); S* ?. K4 E) T& q ~3 I) R
StringSplit, word_array, full_path, `n- e; B% S! ^7 t
; Take the first element from the array: q( @' S9 G7 C: a
full_path = %word_array1%
" W5 d/ h) @' D( B9 R ; strip to bare address
0 ]! ]- q6 C. }2 s8 G full_path := RegExReplace(full_path, “地址: “, “”)
! [6 X u. C5 @* M ; Just in case – remove all carriage returns (`r)
0 O. E* z9 a5 W) E StringReplace, full_path, full_path, `r, , all% R9 \( c$ T! f0 w; N0 e8 ? u
IfInString full_path, \
5 Z) v8 r- W6 L3 P w% F1 w {
8 F- l; e/ s& ~2 g# O9 P2 {3 D u Run, cmd /K cd /D “%full_path%”3 o( U3 D, t3 I
}
7 f( \0 i2 |1 l7 |/ u* n$ B- \ else% P# v/ F/ n7 w. ]& V! I
{
# p1 F1 }4 x$ t Run, cmd /K cd /D “C:\ ”( r6 o5 @, [. W: J5 c e( k
}
: B9 B5 ]- O0 f ] e }5 s' a( Z5 v- F/ q' ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% v% f+ V4 F6 e0 p' m 这段小代码肯能有两个你需要修改的地方7 z C$ J) s2 h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# w7 z7 h2 z& ]0 n; V 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( F9 o3 A9 m' _( }; @0 ]
|