此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* ]- [3 R0 q! N
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' D# O3 ~. E" I( G4 r$ M
方式一:
% k2 R' R$ j/ L z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- i. u# p) j9 i- n* I3 E; T
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; Q$ e$ y7 s+ t+ U5 c5 ]
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! m1 i' {6 p+ s
方式二:
7 J8 X3 \/ i; s% o' e+ h! {8 b 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 Y( I' v. S' X
SetTitleMatchMode RegEx
' D: L/ i- G. \9 [; \6 u return
" x9 I7 z, ?8 y/ q: Z ; Stuff to do when Windows Explorer is open
) Z; L1 {8 {3 u% V; ?& j! r# A ;) J3 c9 q5 ?/ h$ G
#IfWinActive ahk_class ExploreWClass|CabinetWClass
0 ^3 k" U7 o7 ~* [; z! s ; open ‘cmd’ in the current directory
# c |0 ^* K# d9 W" }' e ;
1 X5 {/ B( q% [5 |7 U #c::
4 A% v: b- w, k OpenCmdInCurrent()' g, ]% S0 A# r! A1 O! f
return. w" G2 Y' W' q% q
#IfWinActive
* Y- [& g2 }# _2 i5 e ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# T; w4 f# g+ O% B2 I3 f7 F ; Note: expecting to be run when the active window is Explorer.
8 x @, V& }# ^) f) O$ e" e ;
3 h7 U: c+ i1 l9 p# B4 i# c OpenCmdInCurrent(); a9 Y! l1 b2 @" L7 F
{% ]7 x/ w, h! B/ q4 }- f+ B! l* `, b
; This is required to get the full path of the file from the address bar0 Q1 e2 N( i; ~' [, s
WinGetText, full_path, A
, D0 C: Z4 g! O" z" h ; Split on newline (`n)2 b( X5 }- _- _' x9 e Q6 V3 Y
StringSplit, word_array, full_path, `n( ?! m4 t( V8 X% z) Z: p- o: @
; Take the first element from the array( c% r4 U2 k# V3 r' _
full_path = %word_array1%4 `" q) A6 d2 I$ D, O
; strip to bare address
6 b. W5 g2 e( P% U full_path := RegExReplace(full_path, “地址: “, “”)
& n }9 `& C2 F( ]+ B ; Just in case – remove all carriage returns (`r)
2 `; r; Z" O0 N2 B" S StringReplace, full_path, full_path, `r, , all& S$ u! n6 j6 z& g! M& l
IfInString full_path, \
. R& o z0 [! T" R9 @0 ^. V {
1 Q# y5 Z- ]1 j4 [) ?: |6 \ Run, cmd /K cd /D “%full_path%”) s9 v& [8 D+ w- K
}! e$ R9 ^ q$ M3 T
else
2 n/ T ]* a* x6 f" S! a: c {
; t+ H$ I. K d Run, cmd /K cd /D “C:\ ”
6 R0 w/ B- }1 A% R* @ }
' l6 U% u/ g; l0 P( P" m2 m) Z }' E; L/ v$ h) @8 M2 r
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ M2 z, }0 l* [/ l3 T) s# V
这段小代码肯能有两个你需要修改的地方& z: _6 Y1 \6 j! }: i
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 f8 g2 R+ ^. P8 K2 |% d
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) O$ b2 ^! d5 i* Y: ?5 ]& H" |8 @2 ` |