Skip to content

Instantly share code, notes, and snippets.

@davebrny
Last active November 3, 2023 22:10
Show Gist options
  • Save davebrny/d0e3a42ed3303fc110469b15324230ac to your computer and use it in GitHub Desktop.
Save davebrny/d0e3a42ed3303fc110469b15324230ac to your computer and use it in GitHub Desktop.
(autohotkey) gui function that remembers the previously used x/y/w/h value
xywh(x:="", y:="", w:="", h:="") {
return value("x", x) . value("y", y) . value("w", w) . value("h", h)
}
value(letter, v) {
static prev_x, prev_y, prev_w, prev_h
if v contains +,-
v := eval(prev_%letter% . v)
if v is number
return letter . (prev_%letter% := v) " "
else if v is space ; if empty
return letter . prev_%letter% " "
}
eval(string) {
s := strSplit(string, ["+", "-"], a_space)
return inStr(string, "+") ? (s[1] + s[2]) : (s[1] - s[2])
}
/*
[script info]
version = 1
description = gui function that remembers the previously used x/y/w/h value
author = davebrny
source = https://gist.github.com/davebrny/d0e3a42ed3303fc110469b15324230ac
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment