此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& r1 l! F) t7 v0 E6 `5 E6 M 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 } m9 |, M! L) E3 b
方式一:' F" @/ _! M% ~% `9 e% ^2 K$ `
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' j! `& m5 k; e0 v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ e& [# A; F& C, C8 K
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ T: O9 e* t. C! J3 m! ]9 r6 Q/ H 方式二:
5 d5 \1 ~8 Y v# A5 w* w 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 g$ r$ u1 u6 I
SetTitleMatchMode RegEx9 ~: x# e- R7 H! n9 L
return* u( k3 U2 V, w' R: n n5 O w- z' {$ s
; Stuff to do when Windows Explorer is open+ m3 J4 F* k0 b1 }% \" M
;/ {4 m$ R7 G. i# s) n' c2 q }
#IfWinActive ahk_class ExploreWClass|CabinetWClass8 h$ R: q& O% J( q! c" j# z$ h
; open ‘cmd’ in the current directory
9 D3 {! a+ @8 Y$ a2 X) ^2 m2 r ;
" x4 q) A. I/ f/ u6 v$ ?2 C #c::* r! [9 a& M8 K5 a7 X: {/ U" |
OpenCmdInCurrent()
0 s* H, f. Z5 F/ ~9 Y return L8 \5 Y) f% e9 [3 h
#IfWinActive" U2 _1 Z' i# z& S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 M' `& u8 k4 d+ P
; Note: expecting to be run when the active window is Explorer.
! Z8 v5 n7 c3 Z7 f! P6 Q! k; c ;; p' o/ I: D. ^1 E( d7 H
OpenCmdInCurrent()
% `& E# O8 k. _! N; Z( c {8 @3 s% s9 J+ f: g- e* z* _& {
; This is required to get the full path of the file from the address bar b* q, R' J0 c
WinGetText, full_path, A
# c& j$ H- J1 W: C. S2 {9 s ; Split on newline (`n)
$ F! b$ c% q. I' B StringSplit, word_array, full_path, `n" m; m; P7 o! Q. G* X8 Q
; Take the first element from the array
. D) E$ t/ K- M" S full_path = %word_array1%( D* t+ g% w e) T4 w% `+ T U
; strip to bare address: i) u5 C0 x; \! u |
full_path := RegExReplace(full_path, “地址: “, “”)
( m- J" H& [! s4 q& O$ ]/ s# m ; Just in case – remove all carriage returns (`r)
) @, ]0 G. M, E7 d6 I. ?) P' z* ? StringReplace, full_path, full_path, `r, , all5 n( z6 Z; T' J
IfInString full_path, \' T+ ^% e8 ~7 S4 c6 X! k5 Q2 \
{
% _4 y8 o5 X3 B0 B' M* H Run, cmd /K cd /D “%full_path%”+ U* I" c) l$ ~0 m
}7 k3 w8 h1 z4 C/ D" l) l& x
else
y+ P z8 |7 @4 F {
& F0 _9 H! b% D6 ?" Z4 M5 m Run, cmd /K cd /D “C:\ ”0 w$ Q" ~/ x+ J
}
. u* }5 Y* d1 G5 X$ Q$ T6 V% F2 Q }. M: B3 b4 D# y8 o/ K
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& B2 Z; W) v! d
这段小代码肯能有两个你需要修改的地方
$ Q7 m; Y0 s0 {0 M7 _ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# L0 t6 d) W7 I6 F. x$ x 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( U4 d" M% c0 k/ ~. ?% z; \
|