此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( S0 O n+ E. L
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ w* T+ `4 ~+ A& I$ ]" x 方式一:
h7 N4 s" T% H9 P 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( x: i# {/ }. a6 A7 W% v1 M7 ] 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 M, i H( I/ a! P9 g C5 n! w- A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 i N+ H' X. g' b: |& j 方式二:
4 H, H: q! t* S# ] 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 S4 V9 V$ w- c- L SetTitleMatchMode RegEx! ~4 @; R2 D {) y7 P- [$ u
return. w# q; Z. T& W/ X+ T6 M( B
; Stuff to do when Windows Explorer is open
# P7 b! a2 R/ D3 |- U ;
4 \$ j4 s# y7 M2 i) {; h* G #IfWinActive ahk_class ExploreWClass|CabinetWClass
1 L9 m# d/ p# D; l1 O ; open ‘cmd’ in the current directory
2 `* [4 C7 t1 _: ~" N' W ;2 F0 P5 H: D3 P3 Z, ^
#c::
" A) E4 |8 }5 B& ?* B4 S1 K Q2 M8 x OpenCmdInCurrent()
# P, C5 X% @9 v& ?) h return2 L! ?- E. U' w* |; g# h, o+ i
#IfWinActive$ n8 l. S q; ~0 i' O! i: w9 u {
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& w) F# s4 n8 @8 w# M0 j ; Note: expecting to be run when the active window is Explorer.
+ z3 O" q3 y [/ q7 o2 a, H ;
6 p& g; U- Y% I3 v OpenCmdInCurrent()
4 q; t& K8 I& O {
' |" X6 Q9 E/ T$ E0 b- r3 g. B ; This is required to get the full path of the file from the address bar: t) k! O5 o: _) s( B
WinGetText, full_path, A
3 Q2 x0 Y3 d x! ]2 V ; Split on newline (`n)
5 ]$ f6 N# }, d StringSplit, word_array, full_path, `n
4 o) b N, g; E$ P+ v {3 J" P' Y ; Take the first element from the array9 R( `( k, _9 K. h4 H
full_path = %word_array1%) O, |) _" c. R) X4 E0 Z# i' B3 b
; strip to bare address
. ^" \. k9 Z7 J/ |1 Q full_path := RegExReplace(full_path, “地址: “, “”). g0 _: N& C7 A! L0 d
; Just in case – remove all carriage returns (`r)
+ ^* W8 b% l$ j/ A/ Z StringReplace, full_path, full_path, `r, , all
2 R) f, f9 u* G2 o1 V IfInString full_path, \/ i+ e- H Z- h s
{
, j3 J6 h4 g" b7 F: J( G1 V4 Y Run, cmd /K cd /D “%full_path%”
; c F" \0 V" S }3 D4 |/ F) |* H, ?$ w& {* l
else
3 ^& S+ z' U q& N$ ~ {
+ k% h1 I" D2 W5 T Run, cmd /K cd /D “C:\ ”
8 a* ^/ y, ], Q, [ }6 }9 Q) x- ^6 c
}
0 i! T- a+ A. G& { 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ {, ]; b* |% b$ r5 z
这段小代码肯能有两个你需要修改的地方9 v9 @' U! }9 E* {! L
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 P. W; D: V u5 u" u7 S+ n
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; {: w1 U, ~! w5 M |