此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 E* G5 Q' c6 y/ m/ C* Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" h9 F* s9 s2 o% `+ T8 X8 Q. X& `* [
方式一:. c% N3 S& c( K" U- p
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; ^8 ~% t% l5 g) H0 o 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 t3 P f. s9 g6 `9 p3 Q1 [
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- V" T- K& Y. u% \5 v+ n5 W& y. C
方式二:$ ~# Q; r/ I' r/ }5 U
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 n2 d% R. R4 `& r5 H SetTitleMatchMode RegEx
. V9 }7 t& H8 s3 \! e6 T9 f1 V return) ?% L, F- K; b$ X: ]
; Stuff to do when Windows Explorer is open3 j3 P% H0 P/ O% W) m! A
;! V3 `5 L% q" Z. J' z- Y
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' i T7 ] \6 X+ C; @ ; open ‘cmd’ in the current directory A7 ?+ Z4 @9 Y6 M
;
4 l* V' F/ a" [; E #c::, B6 A' o- V$ [
OpenCmdInCurrent()5 ?6 Q2 B1 ]4 g- I: L+ q0 ~
return
2 X& \/ d% }8 e$ s5 d+ ~ #IfWinActive/ e( D) u% D6 r3 K. u0 k; m7 o/ B- d
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 A# O) C/ `' v4 }1 P* [7 L7 \8 `
; Note: expecting to be run when the active window is Explorer.
* v; a5 H" z" g3 y/ [# Y* y5 K: M ;0 r6 E/ h7 o. J5 D5 \& }
OpenCmdInCurrent()
+ M1 {# `& a% u7 @: d+ G0 m( T3 c7 l, s {/ M% Q; v8 M2 O! Q0 t& F
; This is required to get the full path of the file from the address bar5 d2 h3 ~ L5 }
WinGetText, full_path, A1 g* S+ G3 z% c4 W: ^
; Split on newline (`n)4 L; F7 @1 }( R0 g! k) b* A
StringSplit, word_array, full_path, `n) p; B! a2 z- ?- b& f
; Take the first element from the array
4 ~ ~2 k- E" L: P( g1 ]( T full_path = %word_array1%& W/ w' r3 B1 C7 _7 {- {+ g; p
; strip to bare address% O6 q( q$ [! W0 o$ j
full_path := RegExReplace(full_path, “地址: “, “”)
# N4 K3 O9 f- ~7 G3 t, A9 V ; Just in case – remove all carriage returns (`r)+ Y5 Q% p1 n( Q. H( f5 ?
StringReplace, full_path, full_path, `r, , all
, W, t! Q4 k( l) m% m0 q1 Q IfInString full_path, \0 ~: d# C. B1 J8 ?; [5 q
{
3 S% u3 I) |' J6 H9 b2 j$ n" ^) E6 S Run, cmd /K cd /D “%full_path%”/ E; Z( _# Y, O
}7 Z. _4 S' M: ]8 m3 J: J2 p9 M3 A
else; o+ P- Y+ U, g# g
{; h4 `7 y0 `0 t' M9 U
Run, cmd /K cd /D “C:\ ”- T0 j0 w. }; d) N3 v% g
}7 R2 s$ P( e# g* l* O
}
- V$ Y9 V9 I6 H0 P5 y! v6 @ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 P% A9 N7 b+ W; r! D' b 这段小代码肯能有两个你需要修改的地方7 O0 o4 D N2 O, r. P" [5 |0 S( }
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 j. @6 _/ ~' c0 b' D8 m9 X 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, f7 E2 f) F/ R2 } |