此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" n. ]$ \$ O3 n4 j- n- f* Q2 P) z S 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. m W8 Y$ {# e6 i6 l K( ~' e. b
方式一:
6 M7 r: x; p3 w; ~; E0 a8 t' ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 Y" }- b, i3 l0 L1 k6 ` 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 y2 ~8 [1 p' T! p3 n HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
M% k5 b- [8 V7 W! g3 c2 {2 [ 方式二:8 i! x4 e" v1 h: b( K. `, ^& v
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- { v% i1 X2 ]$ G3 X) \
SetTitleMatchMode RegEx
1 Z4 ]( v; E$ E& }5 U; R5 f return
6 d7 h+ K% f. ^) k2 ]4 g) v ; Stuff to do when Windows Explorer is open
# D4 Z2 f; |1 y4 |" ]* ?% F ;3 B d# b/ ~2 P ^
#IfWinActive ahk_class ExploreWClass|CabinetWClass' d, J3 p0 X$ e& w
; open ‘cmd’ in the current directory; G* V: O. |, L2 d6 j
;0 D/ X' u# i5 \* x; x2 l
#c::2 o7 q7 l7 f% h" G% |" j
OpenCmdInCurrent()
7 d& ?1 ~) [8 j1 }& C* m return0 M- M }+ x( p: ^, I
#IfWinActive
v$ n; V6 U0 Y& W+ b ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 [" y( ]' r7 ~* K- t
; Note: expecting to be run when the active window is Explorer.% ~' ~/ q5 ?) `7 K) I: ?0 [) {1 Q
;# }+ v4 t9 r' ~/ f% U2 q
OpenCmdInCurrent()+ h" t& Y0 i. r
{
- @" a% b1 A2 U: f+ \9 V ; This is required to get the full path of the file from the address bar
, [% Y0 j6 _1 e% T6 K/ J" L8 b4 `( P WinGetText, full_path, A
3 Z0 e/ t. ?" C ; Split on newline (`n)
/ E( o1 u" M% ?/ B, R StringSplit, word_array, full_path, `n$ {$ I2 ?& v i v2 k, M! x
; Take the first element from the array n6 H7 `6 p% Q5 @: x# X
full_path = %word_array1%
. g$ g/ R# z9 A& l* O/ o0 O8 f9 v ; strip to bare address
& q$ A$ I! A& T6 s. e full_path := RegExReplace(full_path, “地址: “, “”)
2 F! |; m w. p" B3 F: P' ]* y ; Just in case – remove all carriage returns (`r)
} u8 I% f. ^3 E& o# [0 W, i* t6 Y StringReplace, full_path, full_path, `r, , all0 ?7 @; Y+ [. z( `8 a
IfInString full_path, \' S8 f2 @9 N. b0 P4 b. J
{! D/ k' H, M! X1 \: L8 G5 g1 b$ u
Run, cmd /K cd /D “%full_path%”; q( L, y+ r) C7 b4 @
}6 \7 @: d' h% y5 d) a O
else
" j% V* k% i, z3 ~" W {
6 `5 f4 d% r4 i8 x/ ^0 G Run, cmd /K cd /D “C:\ ”) J0 H- J6 O! D; @6 j
}
v* i" N" X+ t/ s" s }$ A0 z) z8 f5 V/ w; z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 ~2 n* u" I5 g" t8 h$ M& V! ~' B# P
这段小代码肯能有两个你需要修改的地方. t8 M. d" k, t0 ?* u/ G/ m- B$ `' K
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) S) u; v. G- X7 I8 B3 C7 }% K w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- B; n ]6 S" H |