此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 t" m/ {/ e0 C- ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% G0 y$ n: R7 F6 B# ~/ ]" d
方式一:
0 G0 r' Q4 k, c4 Y6 N0 p 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, ~" ]( N- C3 f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! H! B9 m3 n6 Y e! ~; z- q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 {( E- V5 A$ x+ N- ~4 [* c
方式二:
9 w1 _; v( Y* v0 h8 V3 y, ] 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
c2 N; f. c7 M9 r3 E; y SetTitleMatchMode RegEx+ s# f' }1 Z8 L5 G! `
return
" m [( X& M( Q& @/ y% ~$ @ ; Stuff to do when Windows Explorer is open. _0 q' Q2 c* n! g& h( B% z3 X
;
6 G- F) ~: o% w+ c #IfWinActive ahk_class ExploreWClass|CabinetWClass
4 e- b8 C& e6 ~0 v; B- L ; open ‘cmd’ in the current directory
, f4 @% ~9 Q3 d: W' B: t ;5 U, `' n2 f2 e9 m3 n$ V
#c::' o: I. q" f, a1 H- i
OpenCmdInCurrent()
5 R+ ?# G# O* ~. M7 l# T return
( M# T% O4 x5 ?3 _2 \! i/ T #IfWinActive
4 _( D* K8 J7 Z5 z7 M9 `% r3 G4 g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 O' o! E* N' ?0 `* H ; Note: expecting to be run when the active window is Explorer.
! x8 x7 s+ O" R% D ;
' z: V7 K! ~) S- y# p/ @9 { OpenCmdInCurrent()0 ~9 Y/ w0 d+ }8 d" x1 J `
{
, m4 C0 y$ y+ f( ` ; This is required to get the full path of the file from the address bar+ |7 `! h4 j& O/ g" |0 u9 M
WinGetText, full_path, A
: d8 Z4 @1 x- L( w ; Split on newline (`n)# a7 m1 k, p) `# d) q
StringSplit, word_array, full_path, `n, L& \$ e$ M2 U6 y8 s
; Take the first element from the array1 C3 k( a$ ?9 G) T1 a
full_path = %word_array1%
4 M Q! L k. V$ g' r ; strip to bare address8 l# d& `% m" c# s. s
full_path := RegExReplace(full_path, “地址: “, “”)8 `- t& V. [ j
; Just in case – remove all carriage returns (`r)) r7 h1 e, S: _4 T9 P8 x" E; N
StringReplace, full_path, full_path, `r, , all" |7 w9 e3 c' G- H% P
IfInString full_path, \
0 p, [, s' T3 Y+ b, A& a {8 B$ a% N8 b+ E# ~ B( ^; W
Run, cmd /K cd /D “%full_path%”( }" W* u' Y) `. G' I* {
}! B, z. i# Y/ l) x7 \& r( g
else z/ l2 y/ @4 n' X' N
{( K; r% W9 w8 b( T: p: J7 u% M
Run, cmd /K cd /D “C:\ ”$ k3 p5 p# T6 p% h" U, y2 t
}
1 E4 h: P' i/ [* c% A }* @6 F2 k5 j2 C3 ^' H! @1 h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; K. c$ |6 U7 ?1 y* V) M R( n
这段小代码肯能有两个你需要修改的地方
3 Q# ^ H, t8 z7 [ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ M( l9 h& M) }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 Z3 ]8 e( O( e/ T5 ] |