此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 _7 Z/ i0 Y9 _; p 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) Y* C$ Y9 x/ F$ C4 H
方式一:
8 O1 ~4 m; d* N6 K5 k' R' E. M( w 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 [0 W$ ^; G# b) P
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 v( S. W7 o2 m6 H4 B
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 C- O Y8 }' e 方式二:) v5 `2 \6 s+ |- P2 K
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 h2 B# d' N4 x. e' |: }' V: |
SetTitleMatchMode RegEx
2 i0 T. U2 H, ^) Q7 d' J return$ ~. }# X; _1 x9 f+ @
; Stuff to do when Windows Explorer is open
& O/ i5 _0 e) e" Z' D3 }% T ;2 L- o6 d% L) P
#IfWinActive ahk_class ExploreWClass|CabinetWClass
; s8 g4 B/ G- e# D& O ; open ‘cmd’ in the current directory v+ {) p& J5 I$ k
;
4 F4 z4 @, j2 N! U0 C- A #c::
; g7 ] B- s; { OpenCmdInCurrent()
5 U6 m/ `1 P) S$ t8 _8 ? return; p# y3 ]' G6 r5 H1 Y# U2 J
#IfWinActive/ i6 N0 c4 X! H9 N" K; a0 h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 B5 i& H$ I6 T1 [% ]0 O/ M( l ; Note: expecting to be run when the active window is Explorer.$ j. M5 W* k. k' d
;7 f1 n; P% l- z J5 M1 Q
OpenCmdInCurrent()
- S% ]2 f/ S" y+ W R8 c, C! h {
. C3 y: W: c, \$ U7 v ; This is required to get the full path of the file from the address bar
& W" }& V) n0 r6 L WinGetText, full_path, A
' c# ~- h1 x4 _ w' _ ; Split on newline (`n), ?7 ]6 Z/ a/ L: Q
StringSplit, word_array, full_path, `n; @% {4 X) G: o! G; D
; Take the first element from the array6 v. D0 g' h, ?9 s, O3 z
full_path = %word_array1%
7 j/ v4 `: \8 S- S ; strip to bare address( y; Z( S# H) }1 ~& R% g' q4 Z/ W
full_path := RegExReplace(full_path, “地址: “, “”); G7 }8 R5 h- N; _# X& F' }, ]& y
; Just in case – remove all carriage returns (`r) j7 V" A5 j& n# i0 [
StringReplace, full_path, full_path, `r, , all( Q/ d i' r1 `8 O
IfInString full_path, \9 x% ]# A$ e2 m
{
; v' F) E1 R% @& d: z Run, cmd /K cd /D “%full_path%”# l3 ~- e- m, n2 ^0 ?0 ?
}
& D2 k; H7 y' v C3 \) Q else. h. N5 ]. Q4 P+ x5 H
{$ c$ T$ d. T5 z# E& P' P
Run, cmd /K cd /D “C:\ ”' l0 Z2 }4 b0 Q0 i, X4 ~, Z2 D
}
! [* a$ M" A2 y" p% a4 r' E( | }
5 s' U+ ^$ B x 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 F4 v* b$ g7 e _$ \% Z
这段小代码肯能有两个你需要修改的地方2 C3 |8 D1 D- [/ U" \
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& c m) z/ k, k/ W( E% K7 U& i8 Q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# c" u/ S$ g6 W# _
|