swagfag wrote: ↑19 Nov 2018, 11:14
Code: Select all
#NoEnv
#SingleInstance Force
SetBatchLines -1
SetTitleMatchMode 2
GAME_TITLE := "ahk_exe notepad.exe"
X_OFFSET := 50
Y_OFFSET := 50
hCircle := makeCircle(0x00FF00, 200, 2, 140)
SetTimer MoveCircle, 100
Return
MoveCircle:
if (hGame := WinActive(GAME_TITLE))
{
WinGetPos x, y, , , % "ahk_id " hGame
Gui %hCircle%: Show, % Format("NoActivate x{} y{}", x + X_OFFSET, y + Y_OFFSET)
}
else
Gui %hCircle%: Hide
Return
makeCircle(color, r := 400, thickness := 10, transparency := 254) {
static HWND := MakeGui()
; https://autohotkey.com/board/topic/7377-create-a-transparent-circle-in-window-w-winset-region/
outer := DllCall("CreateEllipticRgn", "Int", 0, "Int", 0, "Int", r, "Int", r)
inner := DllCall("CreateEllipticRgn", "Int", thickness, "Int", thickness, "Int", r - thickness, "Int", r - thickness)
DllCall("CombineRgn", "UInt", outer, "UInt", outer, "UInt", inner, "Int", 3) ; RGN_XOR = 3
DllCall("SetWindowRgn", "UInt", HWND, "UInt", outer, "UInt", true)
Gui %HWND%:Color, % color
Gui %HWND%:Show, xCenter yCenter w%r% h%r% NoActivate
WinSet Transparent, % transparency, % "ahk_id " HWND
return HWND
}
MakeGui() {
Gui New, +E0x20 +AlwaysOnTop +ToolWindow -Caption +Hwndhwnd
return hwnd
}
for cleverer ways of keeping the circle in sync with the window, look into implementing a shell- or wineventhook
hi, thank you very much for your help!
it works great, but theres something i dont know how to determine, its about the coordinate and the how to change the size of the circle
first off, the coordinate, you set in x50 and y50, but when i check with autohotkey's window spy, in the "relative" it said x150 and y150, so how do you set the coordinate so its appear at the precise coordinate that i want?
and then the diameter of the circle
this code > hCircle := makeCircle(0x00FF00, 200, 2, 140)
i tried to change it to this
hCircle := makeCircle(0x00FF00,
300, 2, 140)
it does make the circle bigger, but all of the sudden the circle moved to the right a bit, like the coordinate is still the same in script but the circle moved away because i made it bigger
can you help me on this?