此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( v+ G. Y" v) H/ b( G a' Y% g, b 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 M* G7 Y$ h- b( [: ^) c 方式一:! p, c( l* E* ]" T0 v4 {3 [+ @
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* p1 H/ b K2 D& K
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( f' l4 A$ j4 Z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 d: |( G% g- u; t$ g+ U$ `9 L/ F1 J; M 方式二:
( j5 k6 i( N1 a! ?& D 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ o2 N! C8 y- J/ r
SetTitleMatchMode RegEx
9 `( V: L+ D% W" B" Y* ^+ j return
0 t+ r3 r4 U& }$ R G/ s ; Stuff to do when Windows Explorer is open
9 U8 g" s& _; e4 J ;, W8 a( k6 X& {
#IfWinActive ahk_class ExploreWClass|CabinetWClass
+ i1 P2 M/ L0 Q3 A3 T ; open ‘cmd’ in the current directory
( L& Y) O% @9 ~ ;
2 C0 g: F) h* I/ G7 t( i #c::( ~2 F3 e2 F/ b9 `1 {
OpenCmdInCurrent()2 s: V9 a# ]. @
return
& Y g4 | C* ]+ c #IfWinActive- g* w6 T' h. H% j/ r/ B
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! @9 r' G/ x6 p
; Note: expecting to be run when the active window is Explorer.9 v5 M1 ?- T/ M4 e
;
, t8 L, s( S& n0 a$ a; S OpenCmdInCurrent(); O& N" @6 E( \4 i9 s; z
{
( Y) V7 U" [/ K& D% y& d5 Z- Y+ K ; This is required to get the full path of the file from the address bar5 @/ L' U, I/ Q9 g7 g
WinGetText, full_path, A
) P2 E, {! z4 U) U- I2 r" p6 [8 V ; Split on newline (`n)
& e; o" \& @- K) C* Q StringSplit, word_array, full_path, `n6 t5 _7 t \' Y
; Take the first element from the array8 f! V2 H/ k+ |: P. n
full_path = %word_array1%8 b; a. I: C6 j5 p
; strip to bare address# l; Z% E: Q& L7 u
full_path := RegExReplace(full_path, “地址: “, “”)3 a1 K9 e; }( k- m( V2 j$ Z3 x
; Just in case – remove all carriage returns (`r)
) x3 E2 {+ `1 e. _ StringReplace, full_path, full_path, `r, , all
+ J' l0 Z' q! G0 y% d1 T9 ^0 M' m IfInString full_path, \
8 \+ t) @' ]$ |- _ {1 l2 b0 X" F7 m$ i. h, A
Run, cmd /K cd /D “%full_path%”
+ A; z) |- Z! |( x* h, z8 \- B }5 x9 E, [+ Y# w, n
else7 v3 d8 c5 e: _, K! A
{% T. ?! }4 V5 Q: a$ g
Run, cmd /K cd /D “C:\ ”
5 i: O6 z' O& K$ i }9 E( d* a2 m3 v
}
" n( p* H7 m& {" S& Q" m/ ]& } 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 x U4 N8 H- I' Y
这段小代码肯能有两个你需要修改的地方5 X, }+ ]. W, g" C
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) B4 I2 h; O$ l) ^4 Z! k
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ V; z) y/ o2 e! u+ ~+ y2 Q$ @
|