此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! Z5 Y" S6 [& {* a* d. g4 T) Y5 Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 R3 m! N6 V, [( P- }
方式一:! D2 X! ~' j9 N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% k6 T: i8 R8 W2 N( C# f 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( q% v4 r# I6 t3 g9 M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' [( x z; @: L4 M
方式二:2 b" ^! }% h: ?9 ^8 K
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! R2 A# B3 F+ f SetTitleMatchMode RegEx
- c! [/ h- T! l+ f& A( t. N, r return
$ }. Q6 Y. D, B% e! r ; Stuff to do when Windows Explorer is open; n% Q; ~4 o3 Z. J5 @: A- ?
;
1 R: O& j2 l! F #IfWinActive ahk_class ExploreWClass|CabinetWClass4 g. b3 o5 A7 u% J9 H
; open ‘cmd’ in the current directory
' l5 @5 q5 ?- E" C9 W {& r* ` ;6 @5 }9 n) }7 ^& g
#c::
* e6 H6 U- e2 { OpenCmdInCurrent()
; q% O1 D# R2 h, [% f: D+ c return
' I6 a4 O) E9 g2 r6 Y! k #IfWinActive: x _& K" Z1 ?: C: h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- C* O6 J+ w- o$ O" Q ; Note: expecting to be run when the active window is Explorer.- W( U5 i7 h7 d! v
;$ @# e2 B! M( ^
OpenCmdInCurrent()/ f# s: S, a m6 m$ w
{
5 i" L: y4 g1 } ; This is required to get the full path of the file from the address bar* x# `% n# t I* I* d( E+ g
WinGetText, full_path, A
0 L: }- c5 M0 p7 e ; Split on newline (`n)
+ z2 K5 T4 l0 O1 }# f* |& d StringSplit, word_array, full_path, `n& _8 A5 Q6 u ]$ S! [/ T" X
; Take the first element from the array2 f0 N6 ^6 Z1 d } p$ R+ d' b
full_path = %word_array1%$ `* L' K q/ }2 f
; strip to bare address
' i" _: f8 S7 X; r: Q7 [; V; u full_path := RegExReplace(full_path, “地址: “, “”)$ {# u& d1 M3 W
; Just in case – remove all carriage returns (`r)9 b( J3 S) g& c5 T* Y
StringReplace, full_path, full_path, `r, , all( J8 L ?1 ~8 F. Y6 ?
IfInString full_path, \9 s8 N& z8 G/ y1 e! \5 F9 [
{& B: H- _! u9 ~4 b+ Y
Run, cmd /K cd /D “%full_path%”
, {" c% Z7 x+ M2 D& P }- k9 p6 H6 I/ L# t2 u! q& M) Z
else1 k" r2 q' k) b: K$ R j& S0 T+ D
{0 ~$ t+ f7 `; S# q
Run, cmd /K cd /D “C:\ ”8 Q& S- t6 c5 L( t- K# K0 P
}1 m% \' Z; \+ ~
}# h5 J7 ^! I& {2 T. }
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' S2 C" l- Q; x! z9 J 这段小代码肯能有两个你需要修改的地方
! p3 I& t" T1 k 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- |$ j; V/ r+ P
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 U. I: |6 x- B2 }; o
|