此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 P7 Y# c9 Q4 `2 j* R( d, Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ P. M6 ~! o- B# M' _0 v& `) { 方式一:% o' W- G/ V+ z ]3 p: E! R4 q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( e8 O \/ e( |" o
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 |0 K; ]- I# ], L9 J! ` HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 q7 x8 P! B; P* V3 u0 } 方式二:) R5 L# C- y _$ T" L U! C
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 \$ T0 H+ e. t7 @; U SetTitleMatchMode RegEx% h5 k( M1 v# b
return
' b m9 z7 z, j# B$ } ; Stuff to do when Windows Explorer is open
4 n4 U% C" ?! J$ t ;
# X/ W6 ^/ C) L! i4 m) y0 I0 i #IfWinActive ahk_class ExploreWClass|CabinetWClass
! m9 n4 ~3 E4 Q. U, ^ ; open ‘cmd’ in the current directory
/ @0 T- E# q) S+ v9 ~8 t2 } ;9 D/ M# E6 j, Z& Z: ~5 w
#c::. k0 E# b' L# h9 w7 r5 l
OpenCmdInCurrent()8 j/ J9 f. X. R% U, ]+ o
return" Z& r- E, z7 _+ Q$ J, ~1 S3 s
#IfWinActive
8 v! W5 @- z: h! R ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 I3 v% `- o7 Z" S6 d8 ^
; Note: expecting to be run when the active window is Explorer. y0 N1 u; ?3 v4 Y6 {& Y. P, S
;
# `8 ]4 B7 A! ~3 E: x; q0 {2 u OpenCmdInCurrent()1 k" G. k, \6 G4 W' E
{
& j0 C% n9 F. K ; This is required to get the full path of the file from the address bar1 ~2 }- Y/ {+ Z r M" D. {
WinGetText, full_path, A6 p$ E6 t' D, x1 r1 o* q5 L; D+ E: ]
; Split on newline (`n)8 J0 e& J( c6 x2 j* v
StringSplit, word_array, full_path, `n; P+ d" D, }2 N7 z+ w, b
; Take the first element from the array
$ e, R; G( C' c* C: f8 q0 \ full_path = %word_array1%
4 ~' D* R4 k4 C' p. h5 Z. P ; strip to bare address- C- ?: ^# @0 _" d) q
full_path := RegExReplace(full_path, “地址: “, “”)
6 g% U0 v! f- m& Y0 h2 ?! e8 J/ C ; Just in case – remove all carriage returns (`r)
+ o$ z. e* N8 q; P* M StringReplace, full_path, full_path, `r, , all- t1 t9 P, C4 i% a
IfInString full_path, \; V: d+ w' I/ a' Y3 K7 Z
{* Q0 K1 R8 C# k2 \
Run, cmd /K cd /D “%full_path%” L3 I& \1 k( i" u S
}. L9 \3 n M" t/ s# |6 r
else
# m, [" }( b2 ]7 _* e {' t3 o B" f: q
Run, cmd /K cd /D “C:\ ”
* R+ F+ M8 j7 Y b" y }
2 H$ ]' d& p! o }# |/ J0 M4 i' i* i0 l$ {4 E
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ ~" {$ S5 I$ u0 q0 o' ~ 这段小代码肯能有两个你需要修改的地方/ O* `" q M$ l# s: S, Y. X
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. q: X2 x! n/ w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" N6 U* |- c9 z$ r0 q; c' c; r- M- M |