此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 m, v. @% Z' ?) D E% U. W
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 t/ I4 W4 z. C( x2 Z 方式一:: m+ z9 i3 C! ]4 u: n3 y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 s- z" ^( O' i. k6 n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 _' t# y5 o( ~" t9 ~, j HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 t B0 n, k5 t# ~1 A- V$ r0 y
方式二:0 ^1 B& a0 J7 W: [/ _, ]1 c5 Z; [* s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 V1 m" {: D+ s5 L4 C: B( D
SetTitleMatchMode RegEx
5 O$ O9 j2 x2 L, n% a% ]+ E' w return
, |: ~: ?1 ^% e# ^ ; Stuff to do when Windows Explorer is open
/ \& j e1 v5 E9 K+ _ ; u2 {9 {! G9 I2 D" y$ T' u
#IfWinActive ahk_class ExploreWClass|CabinetWClass" w2 t6 ~% z1 e- H# N+ ~
; open ‘cmd’ in the current directory
7 {# S( [6 x* L' L$ C$ q ;& f/ W1 e- ~4 M8 d8 j
#c::1 |& Q1 |3 ?/ u" N% z- P
OpenCmdInCurrent()# P. t1 {8 o% c$ _0 r
return1 W# k* N' w' j4 m4 F$ h& Y
#IfWinActive% x' ]# T" n: @, w% I* I/ ?( l
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' m; L0 K) F' A( V" T7 h ; Note: expecting to be run when the active window is Explorer.
3 x4 c& u! C( U! b ;7 Q; U# a N% w! |' W# j! y
OpenCmdInCurrent()/ Y1 S% Q1 J: u% E1 l, T
{
" i: x! @' i& V: X4 ?+ O2 ] ; This is required to get the full path of the file from the address bar* j. i+ \* ]0 k4 N" x2 ?
WinGetText, full_path, A( y& _$ S1 q$ A* K% r/ F
; Split on newline (`n)
: j+ a' ~2 O) }# G- }% L StringSplit, word_array, full_path, `n9 i! \1 x4 Z9 O/ N
; Take the first element from the array
1 c! K7 e8 s4 a: r! l full_path = %word_array1%
% V. o0 P. g" `. q! b ; strip to bare address6 j2 i' H# s0 ]8 a5 r' R
full_path := RegExReplace(full_path, “地址: “, “”)! u: ?* i* v& F& {7 |
; Just in case – remove all carriage returns (`r)
/ N; D8 ~! w u4 G2 J StringReplace, full_path, full_path, `r, , all
( T! m6 c. N/ @; v! }! W% Z; f IfInString full_path, \
" [+ x+ t6 j% A. Z {
5 |8 g: C, t. V& p: M Run, cmd /K cd /D “%full_path%”, a5 o# W: S$ a! l, w4 z; F
}
& {3 c4 l& C7 I else. j% C: R& X7 |, {& ~. M7 t0 S" p) d' c
{# T$ J5 I9 R# a& I- h
Run, cmd /K cd /D “C:\ ”8 c1 i+ \% J. d) f& }
}: ^, Z- L L; P, i
}" I6 _4 l- I* h7 \' j+ f
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) z W- R+ u$ z8 S" p 这段小代码肯能有两个你需要修改的地方
+ g z @/ Z1 u9 r. {2 V7 M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键: u- f% h h* n' i! r4 }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ V: t) g" h ]/ q3 j1 B9 x
|