此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ x9 k7 D1 G3 R' C6 K) \: p: s6 n8 s 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 A9 _/ a- `) b
方式一:1 H6 S; G. D; O0 C' X5 c
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ l$ W, k8 _7 f) l3 V3 T
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ e( w! F; ^8 j, n$ J% O5 A3 M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ r& ] \7 u( u8 U% p$ f, L
方式二:
( ?* S% e: O; g 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 f2 d& w% c/ s
SetTitleMatchMode RegEx
8 F. Z5 Y& n. S: w* m# X return1 N* E) T& Z* r2 b. d
; Stuff to do when Windows Explorer is open
' M; Z- L, l5 E; @( w ;+ t! H5 j$ K$ D
#IfWinActive ahk_class ExploreWClass|CabinetWClass* g* Q4 }1 s$ b4 J
; open ‘cmd’ in the current directory2 o- k% M' z# ]
;
) K3 L" S D" I/ K* C) X9 e #c::8 x, u6 P& P) c) h
OpenCmdInCurrent()
9 ] e7 H4 W$ e; D return Z; Q. T8 c- B4 A7 h
#IfWinActive" L3 R# A( ~ S2 Z7 ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 P1 ]3 I1 N! c* t6 r# q
; Note: expecting to be run when the active window is Explorer.0 f, `' }% v! h8 q; w) t' |
;
& t0 Y% m! C8 m ~* J* ?5 u OpenCmdInCurrent()
) I' `: R g6 Y- G: }4 \/ X {
+ d2 R$ \3 l r0 L6 o( H ; This is required to get the full path of the file from the address bar
1 Y1 [. _+ k* u1 A7 t$ N WinGetText, full_path, A
9 l) q1 |2 q0 T- L ; Split on newline (`n)" y4 E! Z. A! H& a* g
StringSplit, word_array, full_path, `n5 \" ~2 _0 e* y: d2 w
; Take the first element from the array8 \1 S5 p$ n. N: Q* ?; _0 q1 i
full_path = %word_array1%9 A8 m$ W% h. G
; strip to bare address3 i7 M9 `6 Y* r
full_path := RegExReplace(full_path, “地址: “, “”)
& Z7 x% X, K" s6 d; I' B ; Just in case – remove all carriage returns (`r)
5 y; K5 x E. @$ ]" y9 Z, V8 _ StringReplace, full_path, full_path, `r, , all
- y' X' h% r6 [. [) }3 q IfInString full_path, \4 u- i6 J/ G; V
{
) }/ Z7 |8 K5 _* q4 `, \ Run, cmd /K cd /D “%full_path%”
9 N' q6 U& i: j& w Z, T }
2 T9 I& P: \$ C else, e+ |$ b. D' u: t0 [( Z9 P
{5 `! x' K% G3 E$ v# b
Run, cmd /K cd /D “C:\ ”& A. B& f- p0 v) ?7 Y! W/ l2 ]
}
$ A8 y, ~8 N' }. N% P }/ C$ ^6 b0 Q z/ R& K; B
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: o5 x& e( [+ T: f0 G* }
这段小代码肯能有两个你需要修改的地方: a' V$ @$ A% b3 ^6 M/ J* J
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ k# Y/ w! S# ^, j1 v, n Y+ O8 N
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
N7 f& y; c; `( I |