此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 R' Y* o" O1 C2 j 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- L, g* d$ S" ~. u" R 方式一:
5 ~# k; @% M; v. }. O$ P9 d+ ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ S, x& s0 D9 R# m$ K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# v) c! d3 c0 m
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 _3 y( k+ }' W' ]: X8 [
方式二:
; y. b: M1 y( m6 w1 y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 _1 x" u$ R$ v' x SetTitleMatchMode RegEx
4 _+ ~- R4 }2 \! y return5 U' J' N# X* X } ]- g
; Stuff to do when Windows Explorer is open. v! j( h* r4 L* T6 D
;3 r) z. ~# e. X! J9 Q
#IfWinActive ahk_class ExploreWClass|CabinetWClass9 Z3 p2 G: Y6 F8 @
; open ‘cmd’ in the current directory
2 |, C4 J; h. k& I- v2 ] ;
+ d) C. f4 Z6 O- q+ ~ #c::
. j& a) H. V' m8 J6 X OpenCmdInCurrent()7 S( f3 ~; V& U8 Q
return" o8 ?1 i) p7 a, a u0 l
#IfWinActive
M( I& o0 v$ D, C( t8 `! P; z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) }8 n, F8 y' k/ w: L& @9 z8 _
; Note: expecting to be run when the active window is Explorer.
/ h+ b2 `3 c& m7 I$ H5 W1 L ;
; @+ g1 z4 O8 l2 \7 a3 q OpenCmdInCurrent()
+ w: s5 v* m' S* q4 v' G2 E {8 U- n& g7 y- [8 ]" f/ Q+ K: J
; This is required to get the full path of the file from the address bar
% Z, M. g% b1 N/ f0 W WinGetText, full_path, A
( z$ {8 A- X; _0 ?2 a ; Split on newline (`n)
0 [, p" ~: b/ I5 p" N StringSplit, word_array, full_path, `n, N! T2 n6 F5 U, B5 H$ [
; Take the first element from the array
5 \; i) Q R! j: u full_path = %word_array1%
) ]3 d1 C9 S- L/ C5 h3 }: E2 V8 { ; strip to bare address
% p/ B2 ?$ g/ D1 q full_path := RegExReplace(full_path, “地址: “, “”)
% z: g( b" w, p3 |5 P ; Just in case – remove all carriage returns (`r)
# l: }2 P- m" Z' B7 j3 z, @ StringReplace, full_path, full_path, `r, , all& H* [! i1 |4 d( s) o* C$ w
IfInString full_path, \% v) B6 [3 K/ P; o8 c
{2 x' u; |4 Z1 K2 E7 @
Run, cmd /K cd /D “%full_path%”
% V4 h ~7 R M& x% K }" h) s( X4 `% u! [
else
9 [! K; e' s1 s" W# Q {4 W/ y5 L7 Q! S( P
Run, cmd /K cd /D “C:\ ”
* {0 {! ^! ~- C6 L; Y" `0 ^% L4 [ }5 r% P$ K* [, ?! N
}, p- i: ^% U% |6 C+ k5 S
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 f$ k( @0 C+ I: o* |
这段小代码肯能有两个你需要修改的地方, A$ m3 h3 E% |6 J7 s* l4 @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 G5 {' ]8 z6 {: v. J6 |7 T5 X 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 B) l) T9 \* J7 O. X& k |