此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 ?: g8 e' _; {8 a* i) E
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 R" G3 E( S1 V. w) u9 c; d+ x! L
方式一:
8 P/ l8 a: a p9 ^8 n! f( w3 o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: a6 i8 a: {! ~ r* ~2 L
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 U' `# O3 L- E/ ~6 e1 D/ o Q6 j
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. q7 A3 S( }! i3 H0 _7 t 方式二:
6 T( E8 s* S* g- t1 Z* |2 s+ d 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* m& ?3 e$ v6 ^
SetTitleMatchMode RegEx6 H3 s! S& C/ w* i Y
return/ Y' \; C% {( O
; Stuff to do when Windows Explorer is open
8 J/ h' Y- Q: }1 l9 A2 ?, ? ;* F0 W! {7 x' n
#IfWinActive ahk_class ExploreWClass|CabinetWClass, E0 c9 d* `9 J# E, r2 u
; open ‘cmd’ in the current directory6 l- l( p- ]$ N* } D, g! O# V
;
3 n, a- U" D5 B! Y+ k4 F0 B9 I #c::
5 L, ~' _ _- o9 E OpenCmdInCurrent()
4 @# M, C" D0 _: K# I return
- \0 J- o* o" U6 e' ?9 ~0 h9 S. J6 s #IfWinActive1 [, ~& j2 }" d3 }
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 K$ K q0 W& h ; Note: expecting to be run when the active window is Explorer.+ I0 g$ r; n1 Y
;
# X. T; k! d4 I2 B- r0 M1 @ OpenCmdInCurrent()* `' |1 L3 X: H; @4 k
{
& r; t5 `) ?( Q7 ~ ; This is required to get the full path of the file from the address bar
u* j$ ?: m6 T- C3 |3 P WinGetText, full_path, A
( g. m, `; q- w. B! u% q; W ; Split on newline (`n)
( e3 G: O/ B3 |& K StringSplit, word_array, full_path, `n: @) f( ^; y/ P1 }* W; c9 p
; Take the first element from the array
. p# ?! t, }9 x9 z2 p full_path = %word_array1%! i4 n$ Z4 N# c6 R; r
; strip to bare address
2 r$ A7 o' x+ i9 o7 s1 I4 f% H2 U6 j full_path := RegExReplace(full_path, “地址: “, “”)
6 L! q7 o4 R3 ?& P0 C8 e4 K ; Just in case – remove all carriage returns (`r)9 X4 i% V$ s) [# q$ P
StringReplace, full_path, full_path, `r, , all1 O" c6 N2 l" o& y4 Z3 f
IfInString full_path, \
q! Q* W( E3 y! K( q/ ]. m {
) w0 }6 }: a0 b- m8 ?/ q! A8 _ Run, cmd /K cd /D “%full_path%”
" b9 V* z4 M/ ^- C0 Z/ ^4 e }
' G- @8 o7 j2 M4 e" [* w3 \ else
& x8 }5 d$ Q1 z8 \7 r" L" u {
: p- _$ V4 `7 d" [& c Run, cmd /K cd /D “C:\ ”, c$ f& n6 j: Q3 b: |
}' W; }* l" l' o
}# d* `1 \2 H( z2 q$ E, t& Z2 y& a$ P
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 |: L8 D+ O( \* G4 n2 B' Z. d 这段小代码肯能有两个你需要修改的地方
4 b# m. ^2 ]6 M( u+ J 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* m2 K! y! I) r" t
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( p1 _- j6 A- o8 s" e; b6 a
|