此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 \8 Z: _! m! j( L+ [. r 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
7 E) \6 H1 N) I 方式一:
+ Y# z' z6 B, f+ Z6 H$ S; V/ g 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- R( L) Q0 r6 M' u+ E* g1 W 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, A& D# n% t- Z' s: r
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 [ u9 ]- g6 h) `5 `% I2 \
方式二:
7 V* o# O! M$ L& M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; |6 E) i, R5 S z7 U9 c, r7 @ SetTitleMatchMode RegEx6 k G( Q6 j: }& C: U9 Y! X
return
5 g1 J/ I4 I. t. c$ n ; Stuff to do when Windows Explorer is open
# p' a+ t$ Z0 M: q7 B ;2 H. U) _9 V* o& O
#IfWinActive ahk_class ExploreWClass|CabinetWClass. q- z2 A; M" T: T4 S
; open ‘cmd’ in the current directory) P, |* Z/ V' e$ _4 g0 {, C; U5 o
;
7 n( E# ~! t$ a7 c% z7 j #c::
( l6 c5 {6 Z; H$ J. V, k OpenCmdInCurrent()* y+ W; `6 p" {) u; X6 y& d
return/ a1 j0 z/ \. _ w' r/ O" S0 p
#IfWinActive
j3 w" A2 v: e8 |1 [5 Z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 N4 H' V+ |9 Q" J- q+ d6 ^% L ; Note: expecting to be run when the active window is Explorer.8 W6 {% G% |3 e9 w# M) h
; ~+ T) N3 m+ X
OpenCmdInCurrent()1 d/ C+ _; a* F$ ]1 A8 ?+ N
{
# n1 v8 w. q$ D: `3 _, `& G+ V+ f ; This is required to get the full path of the file from the address bar
+ [7 j$ L# O% c! ]. `, i WinGetText, full_path, A) Y7 p8 M/ n& X3 E
; Split on newline (`n)% T5 L7 g4 I3 P5 R! ?2 J
StringSplit, word_array, full_path, `n j' K1 o+ R, r r% Q1 ?
; Take the first element from the array
) H: s$ |/ C, |% k& U+ Y full_path = %word_array1% j0 e! k+ a5 F* M- k5 r
; strip to bare address3 o q2 C+ t, Q$ L
full_path := RegExReplace(full_path, “地址: “, “”)8 U2 f1 J5 t4 Q& ?$ P/ j
; Just in case – remove all carriage returns (`r)
8 U$ p2 E0 g, m8 |0 I StringReplace, full_path, full_path, `r, , all
; l# P/ @& S% S% D4 R IfInString full_path, \5 L- z& ], g* w3 d' J- G. a
{
3 c6 E8 z o1 X8 B& V' l Run, cmd /K cd /D “%full_path%”3 u' P8 t1 ~( J" c0 ]5 T7 L
}
" r/ [4 ?' a% e# o else$ A6 t" N: ]; x3 `" ]
{
' Z, S9 Z5 l0 n/ k$ [. n1 @+ c Run, cmd /K cd /D “C:\ ”5 h( i: d4 Y8 z8 Q: u
}% A% y& g! j& k Z" n
}
# R, d4 \; {$ U0 y( Z% L+ y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% b0 C/ I3 Y8 p% q$ a
这段小代码肯能有两个你需要修改的地方2 Z" t" c' A; `" n7 w5 _: _0 F. |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- S: v( r* ~8 Y5 m( `! q) A# q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& [/ |4 L& @" M; l8 Y0 \: ~% u' B; @+ | |