class CircleProgressClass { ; http://ahkscript.org/boards/viewtopic.php?p=41794#p41794 static Version := 1.02, WebSite := "http://ahkscript.org/boards/viewtopic.php?p=41794#p41794" __New(Options="") { this.BarDiameter := (Options.HasKey("BarDiameter") = 1) ? Options.BarDiameter : 120 this.BarThickness := (Options.HasKey("BarThickness") = 1) ? Options.BarThickness : 25 this.BarColor := (Options.HasKey("BarColor") = 1) ? Options.BarColor : "ff22aa22" this.BackgroundColor := (Options.HasKey("BackgroundColor") = 1) ? Options.BackgroundColor : "ffffffff" this.TextColor := (Options.HasKey("TextColor") = 1) ? Options.TextColor : "ee000000" this.TextSize := (Options.HasKey("TextSize") = 1) ? Options.TextSize : 11 this.TextRendering := (Options.HasKey("TextRendering") = 1) ? Options.TextRendering : 5 this.TextFont := (Options.HasKey("TextFont") = 1) ? Options.TextFont : "Arial" this.TextStyle := (Options.HasKey("TextStyle") = 1) ? Options.TextStyle : "" ; you can use for example "Bold Italic" this.X := (Options.HasKey("X") = 1) ? Options.X : Round(A_ScreenWidth/2-this.BarDiameter/2-this.BarThickness) ; centered is defualt this.Y := (Options.HasKey("Y") = 1) ? Options.Y : Round(A_ScreenHeight/2-this.BarDiameter/2-this.BarThickness) ; centered is defualt this.W := this.BarDiameter+this.BarThickness*2 Gui, New, +Hwndhwnd Gui %hwnd%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs Gui %hwnd%: Show, NA WinSet, ExStyle, +0x20, % "ahk_id " hwnd ; click through style hbm := CreateDIBSection(this.W, this.W), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm) pPen:=Gdip_CreatePen("0x" this.BarColor, this.BarThickness) if (pPen = 0) { ; GDI+ is not started up - start it up now and shut it down in __Delete() automatically pToken := Gdip_Startup() pPen:=Gdip_CreatePen("0x" this.BarColor, this.BarThickness) ; call it again (with GDI+ started up now) } G := Gdip_GraphicsFromHDC(hdc), Gdip_SetSmoothingMode(G, 4) if (this.BackgroundColor > 0) { pBrush:=Gdip_BrushCreateSolid("0x" this.BackgroundColor) } this.hwnd := hwnd, this.hdc := hdc, this.obm := obm, this.hbm := hbm, this.pPen := pPen, this.pBrush := pBrush, this.G := G, this.pToken := pToken } Update(Percent=0, Text="") { Gdip_GraphicsClear(this.G) if (this.BackgroundColor > 0) { Gdip_FillEllipse(this.G, this.pBrush, this.BarThickness, this.BarThickness, this.BarDiameter,this.BarDiameter) } if (Percent>0) { Gdip_DrawArc(this.G, this.pPen, Round(this.BarThickness/2), Round(this.BarThickness/2), this.BarDiameter+this.BarThickness-1, this.BarDiameter+this.BarThickness-1, 270, Round(360/100*percent)) } if (Text!="") { Options := Trim("x0 y0 w" this.W " h" this.W " Center Vcenter r" this.TextRendering " s" this.TextSize " c" this.TextColor A_Space this.TextStyle) Gdip_TextToGraphics(this.G, Text, Options, this.TextFont, this.BarDiameter, this.BarDiameter) } UpdateLayeredWindow(this.hwnd, this.hdc, this.X, this.Y, this.W, this.W) } Clear() { ; Just clears the graphics and updates layered window. Doesn't destroy object nor clear resources. Gdip_GraphicsClear(this.G) UpdateLayeredWindow(this.hwnd, this.hdc, this.X, this.Y, this.W, this.W) } __Delete() { Gdip_DeletePen(this.pPen) if (this.BackgroundColor > 0) { Gdip_DeleteBrush(this.pBrush) } Gdip_DeleteGraphics(this.G) SelectObject(this.hdc, this.obm) DeleteObject(this.hbm) DeleteDC(this.hdc) if (this.pToken != "") { ; GDI+ was obviously automatically started up in __New(), and therefore shut it down automatically now Gdip_Shutdown(this.pToken) } hwnd := this.hwnd Gui %hwnd%: Destroy } }