此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' q/ M3 L4 E& C1 g/ w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' r; M- h9 o3 @9 @7 r
方式一:
0 N& o) b4 u% F& @* ~ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; J3 [9 y0 A4 K) X% N* n& a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 l- U w0 S2 r( f0 U+ A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 r) H+ D V* A+ L8 x
方式二:
' M, ~# D: U( j2 r+ h+ o9 T 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 _' I1 i) K+ u* x
SetTitleMatchMode RegEx
4 A/ r8 {% j! q: l return1 {* ~' [4 i3 K+ r. A
; Stuff to do when Windows Explorer is open; @) A" s0 h! B7 F
;& Z3 C4 u. j( ]9 T
#IfWinActive ahk_class ExploreWClass|CabinetWClass
* U9 c8 b. W g, b9 w" Z# W ; open ‘cmd’ in the current directory( ?* n7 j0 a9 v
;
+ N! Q+ h( Y7 d #c::
5 \* K. P- i& e5 N- l1 f6 Q& Q q" P OpenCmdInCurrent()% D3 r; E+ s1 j- a( T
return7 r7 _0 H" Y9 n! U4 A# j" w+ |2 I& j
#IfWinActive
) l5 Y0 ?0 T; | ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& o; @% G" C, X, `7 S2 ?! P; f ; Note: expecting to be run when the active window is Explorer.& j) h x/ P3 {" z1 w. H# g+ h
;4 u0 }; _" ^- H9 M7 r# b+ q* L. o
OpenCmdInCurrent()
6 E. o3 p+ `& s9 @8 a, q {
9 a4 f" M) D3 E/ q0 n5 ` ; This is required to get the full path of the file from the address bar( C) Z( H# M' w
WinGetText, full_path, A' C- {/ D! W$ I
; Split on newline (`n)$ O) d( _+ W4 d7 W
StringSplit, word_array, full_path, `n8 H# q% |8 |0 X- d' {
; Take the first element from the array+ }7 _: p. S6 e4 Q' P
full_path = %word_array1%9 T1 Y! y8 X9 L( J
; strip to bare address/ f# T9 a* i, B9 I, m- A& Z
full_path := RegExReplace(full_path, “地址: “, “”)
% c. t; K7 j0 o; A1 `2 J ; Just in case – remove all carriage returns (`r)
5 P6 e1 Y6 r" R# G; s StringReplace, full_path, full_path, `r, , all
" D; c$ j" Y+ ~: A% W+ W* A. v# D IfInString full_path, \5 V; w' u! x% k0 l* J- m: z6 g
{* Z5 w3 S) d1 O2 Q
Run, cmd /K cd /D “%full_path%” C: r' W6 m+ z. U3 w" ], n+ g) @
}
' X+ v; f, |* j9 | else B. b$ o7 g4 L4 q
{' R* @7 }$ [. w
Run, cmd /K cd /D “C:\ ”
: t4 j! E5 d. p- g }
0 b3 I8 A: j2 D& o) Z2 j) | }
! P9 ^; b9 G( `$ t 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; ?: x$ K1 S+ D4 _3 B1 x 这段小代码肯能有两个你需要修改的地方! J, E) n. V; U9 C2 i/ Y4 p6 h" U
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ q( z2 ]* I; p" S
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 `" d. |9 y8 l- }" ]( Y, j5 Z, K& [ |