此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% f) K# A/ G" } 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 f9 }5 S+ m6 T; W& N8 k# m" c
方式一:! X4 A$ t+ S3 [0 S
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 [9 u- C7 d# }; [ }) ^
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% c+ F; u5 _- [9 n4 u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 Z4 c# B7 {9 i, `& ?
方式二:3 d. H; p' ]2 r0 o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( M) n w5 N Q y. [* n# \2 `
SetTitleMatchMode RegEx: ~- X- t7 ]; v- o, k# Y+ w. O
return
( c# P% u# Y, c6 s4 Z; {+ M5 y& Y! ` ; Stuff to do when Windows Explorer is open5 j$ o! R5 E9 q! y$ T [+ Z
;
& N2 K; \5 L& q/ c #IfWinActive ahk_class ExploreWClass|CabinetWClass6 x9 e! R% J5 O5 |: w
; open ‘cmd’ in the current directory
1 {' q" |1 p$ I9 f8 Q ;
6 T( m0 k0 K: G% X$ e8 \7 Y #c::4 A" ?2 F8 F7 r
OpenCmdInCurrent()& H c. Y, U; z. Z! t
return0 h2 @# b( n t& `. \/ b Y0 }( c
#IfWinActive$ f6 C: w' p: @+ Q" `
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. z8 v! A' e7 ]0 A ; Note: expecting to be run when the active window is Explorer.: r& ]- H2 A' j& c3 P+ L) ], A) R
;
?5 c& s d1 j- O7 h. K1 i+ X OpenCmdInCurrent()" Y2 c) s8 w/ ?. Y# l
{
, o1 w$ b1 Z' M$ y ; This is required to get the full path of the file from the address bar' i+ Q, h- g% z) F# k, r
WinGetText, full_path, A; a% x! t1 j0 S" Q+ G
; Split on newline (`n)7 L& n7 K' F" f! {8 V
StringSplit, word_array, full_path, `n
' @ n/ N9 a ] ; Take the first element from the array
0 C0 g m. K) v$ c- z- {8 D; _( ` full_path = %word_array1%
, B$ }5 \, P) @% ^9 F$ R; b( ^ ; strip to bare address& b( G& {7 B5 f# C
full_path := RegExReplace(full_path, “地址: “, “”)5 C1 J- l+ k: i9 ]! l, a1 u1 a! U% o
; Just in case – remove all carriage returns (`r)' N. x; ^+ X& C& [& E2 ^% S
StringReplace, full_path, full_path, `r, , all
3 _* y- u- M$ B6 s; A0 X$ k4 V IfInString full_path, \+ P8 I# B6 |1 c4 B6 W
{
# M& a) S" f" ?8 ~& t Run, cmd /K cd /D “%full_path%”
3 k- i! J/ n- p& v }* ]# W6 `, T5 A8 H" Y# G
else
, }2 E. s6 b1 ]; I {
# }2 u2 S8 p3 H6 z; Y Run, cmd /K cd /D “C:\ ”
" i J3 R) q* p5 Y6 o! r6 o }
8 o, o4 c# p/ E4 J0 a }! F1 g: u$ P8 K
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& r2 U/ J" B" I: t8 k
这段小代码肯能有两个你需要修改的地方$ H& D) I! J# D: @1 O& j6 _; \
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 k! ~/ m5 v* {' g) D: f$ K
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; M D/ {5 |: p7 R: t8 d7 u* a4 W
|