Skip to content

Instantly share code, notes, and snippets.

@mark05e
Created September 30, 2022 10:34
Show Gist options
  • Save mark05e/89908cbfe06522f7bd725b2d39fee804 to your computer and use it in GitHub Desktop.
Save mark05e/89908cbfe06522f7bd725b2d39fee804 to your computer and use it in GitHub Desktop.
Autohotkey sample to show how to draw a box on screen
; Autohotkey sample to show how to draw a box on screen
; https://www.autohotkey.com/boards/viewtopic.php?t=25520
#Persistent
global border_thickness = 10
global border_color = FF0000
; ctrl + 1
^1::Rect_Draw(100,100,100,100)
return
; ctrl + 2
^2::Rect_Destroy()
return
Rect_Draw(x, y, w, h)
{
global border_color
global border_thickness
Gui, TheBoxThingy:+Lastfound +AlwaysOnTop +Toolwindow
iw:= w + border_thickness
ih:= h + border_thickness
w:= w + ( border_thickness * 2 )
h:= h + ( border_thickness * 2 )
x:= x - border_thickness
y:= y - border_thickness
Gui, TheBoxThingy:Color, FF0000
Gui, TheBoxThingy:-Caption
; outer rectangle
o1a := 0
o1b := 0
o2a := w
o2b := 0
o3a := w
o3b := h
o4a := 0
o4b := h
o5a := 0
o5b := 0
; inner rectangle
i1a := border_thickness
i1b := border_thickness
i2a := iw
i2b := border_thickness
i3a := iw
i3b := ih
i4a := border_thickness
i4b := ih
i5a := border_thickness
i5b := border_thickness
; Draw outer & inner window(s)
WinSet, Region, %o1a%-%o1b% %o2a%-%o2b% %o3a%-%o3b% %o4a%-%o4b% %o5a%-%o5b% %i1a%-%i1b% %i2a%-%i2b% %i3a%-%i3b% %i4a%-%i4b% %i5a%-%i5b%
Gui, TheBoxThingy:Show, w%w% h%h% x%x% y%y% NoActivate, Table awaiting Action
}
return
Rect_Destroy() {
Gui TheBoxThingy:destroy
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment