Skip to content

Instantly share code, notes, and snippets.

@HoldYourWaffle
Created May 26, 2023 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HoldYourWaffle/cf6d2b3b231edeb4f464f05c3af7c925 to your computer and use it in GitHub Desktop.
Save HoldYourWaffle/cf6d2b3b231edeb4f464f05c3af7c925 to your computer and use it in GitHub Desktop.
AutoHotkey - Clip cursor to rectangle
#Requires AutoHotkey v2.0
; Source for AHK v1: https://www.autohotkey.com/boards/viewtopic.php?p=445668&sid=dee54807a74853039237b72c90610eae#p445668
ClipCursor(x := "", y := "", w := "", h := "") {
if p := x != "" {
VarSetStrCapacity(&RECT, 16)
p := StrPtr(RECT)
for k, v in [x, y, x + w, y + h] {
target := p + 4 * (k - 1)
NumPut("Int", v, target)
}
}
DllCall("ClipCursor", "Ptr", p)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment