此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 {0 e8 ^3 ^8 \0 E- Y$ G$ e5 k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' J f- c6 i# _8 [( a 方式一:
$ t- ^" @1 @, E0 U# I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ |+ b0 \7 X+ x% h0 U% { 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 |9 y9 v8 Y4 ~) v' a) D( U HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 M. t$ H+ n7 z& W6 G 方式二:2 U6 ^; w. S+ B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* A0 G2 k% \. N8 u
SetTitleMatchMode RegEx1 o+ e& o- Y" G" a' ]
return6 b7 S; F; L4 e; b
; Stuff to do when Windows Explorer is open
$ j6 ~3 Y, P% t) ?9 ? ;" r8 H" ^2 I3 a- V
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 K' D# H9 O" n ; open ‘cmd’ in the current directory0 k3 m5 o5 J4 J1 }2 |
;- s- |, ~4 {1 m, _( U
#c::% o* ]6 e2 `1 P" p2 G) U
OpenCmdInCurrent()
2 |) f1 |/ s7 g7 z return9 @, f y, V0 ?; K
#IfWinActive) a/ x) Y; B& [9 x! H6 S: ?1 r g
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* J! t+ S6 W8 R9 ?2 X/ s) _2 o
; Note: expecting to be run when the active window is Explorer.- N: K* I5 o9 u: k
;
. A! Y* d! ?: L/ b# X4 b OpenCmdInCurrent()
5 J _' s# O9 V' p# n* N {
$ a3 ]9 j/ e* Y, @% z ; This is required to get the full path of the file from the address bar
! j4 h' H8 R9 Y5 h; ` WinGetText, full_path, A
/ ~! Y4 `6 N' U/ _ ; Split on newline (`n)
& `8 r/ L# F7 E8 f StringSplit, word_array, full_path, `n
) h( |+ C5 t7 w* @7 Q ; Take the first element from the array
7 B- Q& k5 r* u$ x- J# X6 i- G/ Q( v# h full_path = %word_array1%7 R' R! V' j w
; strip to bare address# G S2 s# O$ S, ~, m
full_path := RegExReplace(full_path, “地址: “, “”)+ m5 l7 ^8 _- {# P5 c, z1 {0 L' p
; Just in case – remove all carriage returns (`r)1 c: f2 m% r0 }, s) T% n. w' s; Z
StringReplace, full_path, full_path, `r, , all8 R0 _( j8 j; q. R0 q- f( o
IfInString full_path, \2 Y$ H( e: T" x A7 u0 n% H. z# L
{
2 N, k1 W9 [. k3 \# \+ w( Q! V2 L Run, cmd /K cd /D “%full_path%”
6 c- U8 L" b& O6 w# Y, e( ` }
( j# y+ l J6 d else0 r. b8 O9 R5 [. S5 v( n+ E! d
{7 b4 h) j/ s5 X
Run, cmd /K cd /D “C:\ ”: k v0 u9 j6 v- o6 `5 J
}- d7 t( U$ `- z/ f8 u
}8 z3 l" r* \' P
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* B0 O, i, h: Y2 @0 ]8 P
这段小代码肯能有两个你需要修改的地方
. j+ a( z6 v: [4 O! k4 t 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& q& `$ [1 j* \; J% Y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, M- u# |- A- W) s' k8 p+ G
|