; #Include <Gdip_All> ; 361KB ; 圆形进度条另一个例子:https://www.autohotkey.com/boards/viewtopic.php?f=6&t=6947 ; 坐标和时间 SetSkillCooldown(1000,450,3) Return ; By 墨流 ;调用函数显示计时:x,y 绝对坐标、时间 | 可选:x,y 局部坐标 SetSkillCooldown(x,y,time,x_offset:=0,y_offset:=0) { ; 初始化 local i, v, name if !(IsRuning_ECD) { IsRuning_ECD:=1 if !E_hbm_w SetDisplayArea() initialize() } else { SetTimer, anim, on WinSet, AlwaysOnTop, on, ahk_id %hwnd1% } x:=x-E_hbm_x+x_offset y:=y-E_hbm_y+y_offset time*=1000 ; 是否已有 for i,v in ECDData { if(Abs(v[1]-x)<20 and Abs(v[2]-y)<20) { ;与原有坐标相近,判定为同一个 ECDData[i][3]:=time ECDData[i][4]:=A_TickCount Return } } name:=% x y ECDData[name]:=[x,y,time,A_TickCount] Return } ;设置显示区域 x,y坐标,w,h宽高,默认全屏,调小能减少内存占用,在第一次调用 SetSkillCooldown 函数前才有效,往后只能更变位置 SetDisplayArea(x:=0,y:=0,w:=0,h:=0) { global E_hbm_x:=x E_hbm_y:=y E_hbm_w:=w?w:A_ScreenWidth E_hbm_h:=h?h:A_ScreenHeight Return } ;刷新画面 E_UpdateImage() { local i,v,lTime,laangle Gdip_GraphicsClear(G) for i,v in ECDData { lTime:=A_TickCount-v[4] if (lTime>=v[3]) { ECDData.Delete(i) } else { Gdip_DrawEllipse(G,Epen2,v[1],v[2],23,23) laangle:=lTime/v[3]*360 Gdip_DrawArc(G,Epen,v[1],v[2],23,23,270,laangle) } } UpdateLayeredWindow(hwnd1, hdc,E_hbm_x,E_hbm_y,E_hbm_w,E_hbm_h) Return } ; 初始化 initialize() { global If !pToken := Gdip_Startup() { MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system ExitApp } Gui, G1: -Caption +E0x80000 +E0x20 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs Gui, G1: Show, NA hwnd1 := WinExist() WinSet, Disable,, ahk_id %hwnd1% hbm := CreateDIBSection(E_hbm_w,E_hbm_h) hdc := CreateCompatibleDC() obm := SelectObject(hdc, hbm) G := Gdip_GraphicsFromHDC(hdc) ECDData:={} ;颜色 Epen:=Gdip_CreatePen(0xffEAE7E3,5) Gdip_SetPenEndCap(Epen,0x02) Epen2:=Gdip_CreatePen(0x43EAE7E3,5) Gdip_SetSmoothingMode(G, 4) ; 动画帧数,默认每秒12帧 SetTimer, anim, % 1000//12 Return anim: if ECDData.MaxIndex() E_UpdateImage() else SetTimer, anim, off Return } OnExit("ExitGdip") ;结束清理内存 ExitGdip() { global Gdip_DeletePen(Epen) Gdip_DeletePen(Epen2) SelectObject(hdc, obm) DeleteObject(hbm) DeleteDC(hdc) Gdip_DeleteGraphics(G) Gdip_Shutdown(pToken) IsRuning_ECD:=0 ECDData:={} Return }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)