此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" j/ l( ^; E6 p8 f& Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( Y3 Q) Q9 |$ c4 _2 {6 n
方式一:- I) j# U8 R$ D. X) k9 p u
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: }+ f* A$ O! U. t8 b 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' w( w$ Q# I Q" m
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) _' G3 |0 w( M( |
方式二:
5 V3 L6 x2 {! h4 c 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ v1 ^* G! ]5 K0 S6 [% m, @1 b SetTitleMatchMode RegEx" }8 Y. k7 o8 r& W9 n+ h- C
return
7 w3 n; M& q" K. F/ _7 H% D ; Stuff to do when Windows Explorer is open
) D1 q7 z' n2 C! j2 T, H$ X ;
- _) b/ e8 U, _9 [/ i- Q #IfWinActive ahk_class ExploreWClass|CabinetWClass- U1 w5 X. s& L0 k9 ]( X* Y" l9 K
; open ‘cmd’ in the current directory! h, ]& j$ N0 o% l: z
;7 W. J& P4 R5 z3 c
#c::) m4 |/ W' ^$ x
OpenCmdInCurrent()
% r2 t& e- i* H$ s/ _ return) S, n u3 o& ~, a! U
#IfWinActive
/ |/ U) @# j& f1 |* G6 z) T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% ]# t" r1 e7 B$ p/ [0 g
; Note: expecting to be run when the active window is Explorer.
- [7 l, t6 E' ~, e' F3 m/ e ;; ^( \; q, E: c
OpenCmdInCurrent()+ X3 _" h+ o& L) k, P A0 S; r
{5 d+ g9 l# c% o$ [ g
; This is required to get the full path of the file from the address bar
/ ]) }8 ~2 \: J7 w6 X, y+ X" X WinGetText, full_path, A
: Q# z/ ?. k& ]# b; V ; Split on newline (`n)* P; F+ b% `( d( ~; E4 }
StringSplit, word_array, full_path, `n
7 G1 {/ v1 Q# d1 n. a% j! x ; Take the first element from the array
- E; D# a" j: f; a, a, P& M full_path = %word_array1%4 o. o. f" d# n" m5 Y) O
; strip to bare address: M7 E# z8 s, y6 o" f
full_path := RegExReplace(full_path, “地址: “, “”)( I( O. T$ V1 [
; Just in case – remove all carriage returns (`r)
! X8 I; m: k( O" i' E StringReplace, full_path, full_path, `r, , all, A3 \# p6 N7 ~$ i: B
IfInString full_path, \, }: q6 \8 C( \* e- N
{: [- T7 ~* V2 w7 [6 [
Run, cmd /K cd /D “%full_path%”
- S* x8 ?- B9 c% U6 h' {) N3 z }
" B/ p l, \5 I% m1 p! \ else
+ ?/ _/ u, \ S- [ \+ q6 v! G; T {
" g2 M* I* t0 h% ` Run, cmd /K cd /D “C:\ ”
9 K; w k# R' j& }" U }5 W6 S( _8 |. N* B5 F
}
- g3 W0 Y4 x+ n% D6 B9 g% _ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% ~9 I5 G+ }* n+ T1 T) Z5 O
这段小代码肯能有两个你需要修改的地方3 q: ]9 t2 n U' j8 v0 }- F V: t
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ l$ k+ M# }9 ?! S/ ] 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( h6 {2 d( X" C L
|