此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 Q1 M; R9 S! H8 B& L! L
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ q8 `# j7 y6 B; ^1 J. \! H
方式一: {+ v8 Q7 P' P7 z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 v6 Y5 t* Z9 f! m' c4 B: I 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; N% B* o1 S' E7 q4 M4 ?0 W HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 e' n. K5 x2 f0 \- G9 p
方式二:! D1 q) a! f! P, ]+ L3 t8 x2 |
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 F" w/ [1 z2 {1 F SetTitleMatchMode RegEx m( O9 ~; r0 D, o: e
return) g1 P' T1 k) N8 v1 I% S, L
; Stuff to do when Windows Explorer is open! t6 h: R5 n$ @5 t3 r
;
; B2 |4 Z) q! {# g #IfWinActive ahk_class ExploreWClass|CabinetWClass
4 W& `% P6 u' q! T* u# _- {9 U ; open ‘cmd’ in the current directory
5 ~8 P; W! T Q3 J. ` ;3 C4 t2 i! F! C9 T3 O2 W6 H
#c::
: N' S- F+ q( \/ y& S) | OpenCmdInCurrent()
1 u7 z, g% J+ f4 x; q5 P7 z: W2 P' y return
: Z6 Q1 W) z. Q #IfWinActive$ x5 N1 _/ }5 @" `; G: h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* m$ c; U& k8 u4 t( {
; Note: expecting to be run when the active window is Explorer.1 z3 X, ]; ]) ~9 I6 Q
;
1 D) R- m2 X# T- R# {/ _ OpenCmdInCurrent()9 j, o! S. c; [! D" d+ J9 N% `$ {' @
{
' x' k3 U: }1 u; t2 G( v3 B" P ; This is required to get the full path of the file from the address bar
@1 o# E$ [: V, S& ~$ e WinGetText, full_path, A( B1 `+ P/ n$ X: x+ N* I& d' s
; Split on newline (`n)- b7 T3 Z. T" N
StringSplit, word_array, full_path, `n9 [7 p1 ~ m+ g3 u1 G! {8 q
; Take the first element from the array
\7 v. h/ C9 T5 ?7 r3 F full_path = %word_array1%& |$ ]- S5 Q0 i: {: e" Y5 x
; strip to bare address: J0 n. @) f; e3 Y, J7 C: K+ @
full_path := RegExReplace(full_path, “地址: “, “”)
7 t; K2 ^* z) a ; Just in case – remove all carriage returns (`r)
' r) _7 X' o$ u+ a8 J StringReplace, full_path, full_path, `r, , all8 V$ y$ h8 E7 L' Y. I* i+ m+ I" O
IfInString full_path, \8 Z. N, `8 a' H# a
{3 A! K8 G8 r2 g) I
Run, cmd /K cd /D “%full_path%”! \$ d, Q: Z* j8 H& H% H5 b
}" N3 M2 Y) L! w2 Q
else7 [0 I. w; j' s: V/ o* M0 h t
{8 n: S+ m8 I0 M) [9 x5 l) q
Run, cmd /K cd /D “C:\ ”
$ s% D: \' L& l8 J+ l2 C. L. f }
: L U+ E4 Q5 p. ]: F3 ? }( ?* a" }0 b9 M7 c0 }) Z& p' ?1 ~& f
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 x4 K- |" v- d) e6 T8 s3 U 这段小代码肯能有两个你需要修改的地方
& }& ~. r; g5 i% S' a9 N- L* r/ m 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 {3 R& `/ r; m+ h8 `. S 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& W9 J2 }# G$ S0 Y! ^8 F+ A* U' b |