此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" ?0 A' s7 d8 u& I2 q: r% H. ` N
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 L; o( v6 T5 G* M; Z
方式一:% E$ ]0 C( U8 ]- `; M7 P
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 x" M9 ]) H" _7 J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ U7 `3 Z& z3 U3 l( S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! x1 I+ e$ c0 |
方式二:% T: B# ?3 O7 P
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 i( w- o5 H$ ` SetTitleMatchMode RegEx
3 g) z. d, g d) i7 C return) K2 K, B# ]# ]! b/ ^/ L" t( A
; Stuff to do when Windows Explorer is open8 @% J! D& J+ b$ r; Q4 `) Y/ M
;
3 w: S+ Y" u h/ p, S5 J #IfWinActive ahk_class ExploreWClass|CabinetWClass
* u$ m3 m* j1 E3 [; j ; open ‘cmd’ in the current directory
9 _5 x! ~8 {$ \2 ^0 W$ |) g, a ;
3 s. H" e3 ]" K" q! g #c::
% w) U9 h. w' p& Q9 L5 I9 V OpenCmdInCurrent()
2 _ o# l5 {* Q1 I, L return$ \9 \. q; a1 Q* e* v/ l
#IfWinActive
: `/ ^" D7 J. B4 }$ M7 L ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: X3 U0 p M6 t
; Note: expecting to be run when the active window is Explorer.# C! N, `. e- |5 `! r
;# ^* ^5 a: j! P: h
OpenCmdInCurrent()
1 w" n L4 a, r {
7 E( E7 j2 f( i, I ; This is required to get the full path of the file from the address bar0 s/ j/ m! I: c) F7 o, ~
WinGetText, full_path, A+ U. }8 S" \ ]3 w8 k
; Split on newline (`n)
' Y! \( X u8 R, G StringSplit, word_array, full_path, `n4 p& m: t! a* e5 e+ m. _
; Take the first element from the array$ W" I( q) H5 R- S/ b
full_path = %word_array1%/ H7 B6 Y! B" h Y
; strip to bare address
1 m6 k0 q0 M& }' q, g% i full_path := RegExReplace(full_path, “地址: “, “”)
% i. e9 n2 n2 |3 l& W ; Just in case – remove all carriage returns (`r)
2 I5 G8 h2 \& E% Q0 w StringReplace, full_path, full_path, `r, , all1 \$ N& \. V8 l1 r! h; A
IfInString full_path, \
" Q6 R- E i1 P: w- h* N" @ {' j! r! o% n6 u: K1 c% V, o( `
Run, cmd /K cd /D “%full_path%”
0 C4 w7 E$ n0 g7 x" c }
5 [4 |# Z. h3 e* }/ T2 q- L else
h4 J! u* } S* j& ]7 h* @ {
# \ R% S9 g! M' f& N% [ Run, cmd /K cd /D “C:\ ”
- j0 [ g k. j: z9 Q }4 t$ |8 B( _0 S9 q
}
7 g, n. g- ?3 ~3 k9 R. R 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' V1 n1 J. P' y9 x' l
这段小代码肯能有两个你需要修改的地方; d) s6 ?4 h: |' o6 E
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; [! ~# C" y" K/ p
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 t- N; |% S4 K( b. m
|