此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ g* u5 l8 \* C9 u* a; ^
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) h2 p0 A& C/ h/ \9 A) L0 y 方式一:: K# ]6 x+ _# q9 q2 \, X
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& d9 P; S& y6 k+ t 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 N: I2 @) r( x/ |, _6 d
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- Y- n( P9 \7 T2 r. U" T% r
方式二:6 O5 `! | I0 W* s, u: Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 c7 f+ c. i5 a4 C+ f- ~9 Y. F$ s SetTitleMatchMode RegEx+ Y$ V, W+ e6 P0 k9 k. e. X
return: |4 G) t; q: v' U" Y3 u$ G
; Stuff to do when Windows Explorer is open
8 g& ~, |* E0 r. z. S ;
8 ]' N& y$ Z# e, S! x #IfWinActive ahk_class ExploreWClass|CabinetWClass$ F2 C* D+ ?' ~) g
; open ‘cmd’ in the current directory
5 L6 Z/ a: a* Q ;
% p: h% P1 O1 a: i #c::
; T6 n+ E! b0 C1 K* J( N OpenCmdInCurrent()6 |% |/ z2 @/ y+ O- Z
return
2 [+ P/ S) F! }- H2 A: i: T6 \# y #IfWinActive
6 P, |1 X7 S' C% N8 d ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# [' ]& H! s* O g8 m, v6 x D ; Note: expecting to be run when the active window is Explorer.
* f0 U! w% t# }' j ;- A2 I* {/ H! T: g) I f; T+ z* Z
OpenCmdInCurrent() j' ~& ~& ~! k$ `
{
s) J/ T2 i7 R ; This is required to get the full path of the file from the address bar! D* m$ k3 S) T0 \, ?5 w
WinGetText, full_path, A" e7 O5 {7 C u# q; j
; Split on newline (`n)
& Z% J: e9 a9 e/ V- { StringSplit, word_array, full_path, `n
! a1 g+ I6 ^& m+ ?6 i4 _, j ; Take the first element from the array
- j6 b9 }3 Y I! x full_path = %word_array1%4 b( `+ q' M! N+ F' I/ {# n
; strip to bare address3 n# F1 d9 O! F" R7 @
full_path := RegExReplace(full_path, “地址: “, “”)
4 K q7 G9 L# `4 ~4 \ G5 K9 g ; Just in case – remove all carriage returns (`r)
% l+ u9 z* t8 K9 D' [0 U9 q. Y StringReplace, full_path, full_path, `r, , all N. q+ H3 J- u" c
IfInString full_path, \' j. U* W0 n! D$ h8 U3 I
{
; @( ?9 _+ m: F! o: O9 C9 N9 C Run, cmd /K cd /D “%full_path%”
3 y' |# i4 L' W5 I2 G, o: L7 s }/ x- ~5 P4 {- o0 `" w) ~" s
else
5 f# J2 [% R7 \; T" d. c) S2 {7 [ {
, t- {. H: \. `5 x9 d; h- H$ o' W6 r Run, cmd /K cd /D “C:\ ”
) ]* D5 T; h7 u% j }
5 @+ f) ]. ?; t1 P2 | }
+ y4 n$ _: b2 S% ^: l$ L/ D5 _) R4 o 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' t- S& B& h6 M( ~9 S5 O
这段小代码肯能有两个你需要修改的地方: a- H: {: R- M f3 S9 M. n
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! W2 g4 y$ [" D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 L9 V z" Z0 T: J4 _& R
|