Script to draw a tiny circle

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Super Foxy
Posts: 16
Joined: 22 Feb 2023, 11:28

Script to draw a tiny circle

Post by Super Foxy » 15 May 2024, 16:05

i want to create a script that draws a tiny red circle (say 5x5 pixels) in the current position of the cursor every time I press the the R key, and deletes every circle when I press D. I want them not to disappear when I click or navigate through windows. If someone can help with that I'd appreciate it, thanks!

User avatar
mikeyww
Posts: 28870
Joined: 09 Sep 2014, 18:38

Re: Script to draw a tiny circle

Post by mikeyww » 15 May 2024, 20:35

Code: Select all

#Requires AutoHotkey v2.0
g := []

r:: {
 g.Push f := Gui('+AlwaysOnTop -DPIScale +LastFound -Caption')
 f.AddPic 'AltSubmit', 'circle.gif'
 WinSetTransColor f.BackColor := 'White'
 CoordMode('Mouse'), MouseGetPos(&x, &y), f.Show('x' x - 13 ' y' y - 6)
}

d:: {
 For f in g
  f.Destroy
 Global g := []
}
Attachments
circle.gif
Circle
circle.gif (92 Bytes) Viewed 347 times

Super Foxy
Posts: 16
Joined: 22 Feb 2023, 11:28

Re: Script to draw a tiny circle

Post by Super Foxy » 15 May 2024, 21:28

mikeyww wrote:
15 May 2024, 20:35

Code: Select all

#Requires AutoHotkey v2.0
g := []

r:: {
 g.Push f := Gui('+AlwaysOnTop -DPIScale +LastFound -Caption')
 f.AddPic 'AltSubmit', 'circle.gif'
 WinSetTransColor f.BackColor := 'White'
 CoordMode('Mouse'), MouseGetPos(&x, &y), f.Show('x' x - 13 ' y' y - 6)
}

d:: {
 For f in g
  f.Destroy
 Global g := []
}

Ok so it kinda worked, but it creates a new window every time I create a new circle and I need to have the image, it looks horrible both in gif and png format, and I had to adjust the position until I matched my cursor. However, someone gave me another script on Reddit and it's almost perfect for what I want, but I have to adjust the position and I don't know how. Could you please help me with that? I just need to know where to change the X and Y axes and I'll do the rest.

Code: Select all

*r::show_mouse(1),KeyWait('r')
*d::show_mouse(0),KeyWait('d')

show_mouse(state) {
    static size := 5
    static color := 'Red'
    static goos := []
    
    if (!state) {
        if IsSet(goos) {
            for index, goo in goos
                goo.Destroy()
            ,goos := unset
        } return
    }
    
    if !IsSet(goos)
        goos := []
    
    CoordMode('Mouse', 'Screen')
    MouseGetPos(&mx, &my)
    goo := Gui('-Caption +ToolWindow +AlwaysOnTop +E0x20')
    goos.Push(goo)
    goo.BackColor := 0x1
    goo.AddProgress('x' (mx-size/2) ' y' (my-size/2) ' w' size ' h' size ' Background' color, 0)
    goo.Show('x0 y0 w1 h1 NoActivate')
    WinSetTransColor(0x1, 'ahk_id ' goo.hwnd)
    goo.Move(0, 0, A_ScreenWidth, A_ScreenHeight)
}

Esc::Exitapp

User avatar
mikeyww
Posts: 28870
Joined: 09 Sep 2014, 18:38

Re: Script to draw a tiny circle

Post by mikeyww » 15 May 2024, 22:29

I would look at the AddProgress line where the x and y values are specified.

Post Reply

Return to “Ask for Help (v2)”