此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' [5 |; S& _% G7 U# K
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* A+ q, U. \# I7 a
方式一:
% \' n* _( `# p 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. J& b I1 D, ~& h 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% ~$ H7 {6 o6 `9 x. @4 {
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. e8 T0 N2 z/ k7 `2 Z4 Q
方式二:- l- R s) @- l2 f) @6 j, _. K0 @: V
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 ]$ O& @* v" S& c% I9 r; i6 D+ c SetTitleMatchMode RegEx; c0 D' G: N7 ]6 w$ B- M
return0 ~) f2 P6 q5 @2 f, N) @* S% w
; Stuff to do when Windows Explorer is open: I y8 {# L+ V" f' p' x
;% J1 Z) S! p. @8 J5 u( @5 m
#IfWinActive ahk_class ExploreWClass|CabinetWClass8 ~. t: v" u& \! v- z A
; open ‘cmd’ in the current directory7 D+ Q/ @% B+ \, {) d/ m
;
) J H/ u0 h9 i6 W; m #c::( l2 N( A2 R1 s+ a9 S
OpenCmdInCurrent()
$ F' U2 I3 J* _! s return" M( ?; N8 O! r9 g- j
#IfWinActive7 X( P" x( \8 i4 i9 S0 b, g
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% v3 M" a; i# J2 D8 F- M2 ~ ; Note: expecting to be run when the active window is Explorer.
3 j0 ~* [$ Z6 }* S; v& k, ? ;
. f. E+ c3 V0 `/ D& J( H9 B OpenCmdInCurrent()
& V8 T. Q8 r3 M. t. M8 z {" O: P% t1 V6 y% D7 G
; This is required to get the full path of the file from the address bar4 Z% N7 z( t3 z
WinGetText, full_path, A
" }2 Q0 M. @( s1 ^7 P2 D8 t ; Split on newline (`n)# [' ^' u( x0 D' g) ~8 j$ V
StringSplit, word_array, full_path, `n. ?* ^* M+ [" a6 t6 }. o1 ~2 j
; Take the first element from the array
% E1 C" L. F$ G, L9 M/ [ full_path = %word_array1%! J% r8 X) C5 N: Q" O" b
; strip to bare address
- P6 l4 W5 F7 R. N full_path := RegExReplace(full_path, “地址: “, “”)7 f G% W- b6 n7 ?9 l$ B) a3 y
; Just in case – remove all carriage returns (`r)
) V, C7 c8 V3 p* g# ] StringReplace, full_path, full_path, `r, , all9 M$ n4 K0 M2 W+ P; T2 Z
IfInString full_path, \
; I8 g/ t7 V- @6 q3 x# ~ {, U( n P7 C1 i* u5 X; ^
Run, cmd /K cd /D “%full_path%”* |6 I7 i5 e4 n( A4 f0 M8 G
}
8 Q% ~" G; z! a: U. D( w( q else
. G) S% u, h/ q6 K7 ~, A A {
- j7 }. G# I' q$ \( t Run, cmd /K cd /D “C:\ ”/ L9 b# B; I- A+ R( W8 T
}
; C# g9 @- f1 H }
3 ?; @, e h# }( j 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( G) t% T0 q D8 r( ~0 {. \, z) W& x 这段小代码肯能有两个你需要修改的地方- P6 [ F/ b0 H/ w; i: M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# B1 A/ S+ w2 C3 h: H C 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; l1 _' |; M0 z6 n7 i1 V |