此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 U6 N( ~% `8 q8 s7 `3 J# a
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* i( o' G: |5 b# b
方式一:. s' ~0 i8 Z4 A. z& R! }/ c+ m+ o3 V
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ ~$ f9 n8 h/ I+ A! W9 z/ p 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ {5 h) O2 a6 @2 j2 f9 H HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& `; v3 r( e/ L
方式二:
! T+ z! p5 p* F/ d* M4 z4 f 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- n& h9 r g% O, D' e SetTitleMatchMode RegEx7 E" u( U$ e) o8 T( u
return# Z: R' G- M% O$ N- o3 e
; Stuff to do when Windows Explorer is open
4 d0 B" z J( P! F5 b4 n3 P. B% ] ;
" N- e: v7 {7 R6 n+ K9 V* o #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 U- o& c9 c3 n5 K, o! _! i ; open ‘cmd’ in the current directory
9 [& Q# _5 K9 c: K& h+ O! k ;5 L7 Q: ?6 Z. K! y% V
#c::; K6 N; b6 o1 ? W* v1 Q+ W
OpenCmdInCurrent()! @+ S' y1 P0 `( f [2 ~" x0 L+ h
return+ } D) p& T( V4 }$ V6 [
#IfWinActive* r. _- W# c9 B% h) K% t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% ?$ T ]; {; Q& ^5 C/ S ; Note: expecting to be run when the active window is Explorer.
H8 W6 k6 H$ S9 R( Q3 D$ C( K ;
/ B( h% J. j0 H" q OpenCmdInCurrent()
- u8 O8 n4 ^9 Y1 N- D& O {3 d9 z. x" x. H
; This is required to get the full path of the file from the address bar
3 r. Q/ c9 n' e; k/ h WinGetText, full_path, A
7 H5 I1 F+ s4 ~( Q# ^1 a) A ; Split on newline (`n)
5 |7 g5 z4 D, G8 j, e- @- N StringSplit, word_array, full_path, `n8 _! e, B6 n8 P
; Take the first element from the array
0 k# h( z) \) {( R7 a6 {- s full_path = %word_array1%. [% v! F% M5 J# D" ]$ {* Z
; strip to bare address
$ m; p" D/ e ^/ [3 B8 P7 l full_path := RegExReplace(full_path, “地址: “, “”)
7 R$ s$ l( ?# ^. F+ m: g3 r9 ]3 D ; Just in case – remove all carriage returns (`r)8 F& k! e0 O9 X4 C5 I
StringReplace, full_path, full_path, `r, , all4 A% @+ }/ s: s# K3 c4 F3 K. {6 d
IfInString full_path, \
4 N5 m; [/ s( b! Q {
8 t' t7 d5 E/ s2 B Run, cmd /K cd /D “%full_path%”9 E O" t9 _; f' \5 K3 _
}
1 b- e- E+ X" a+ f5 ~" j else
" I; n; h S+ g+ X% Z; F D {; a& U5 V' r. L% x1 `6 F5 p
Run, cmd /K cd /D “C:\ ”
( w# v# j0 `7 k& i }
# s! Y% R3 ~% p6 I6 e3 e }
# D7 ~+ ?" |6 l# U; |* w1 M 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: n) G$ t: j2 Z) \* i; ^- e; W
这段小代码肯能有两个你需要修改的地方% W' J; w6 m3 p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) A; [( f( K* v) r& X" ] 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. q% ]: f& n5 G3 l4 |8 c
|