I'd like to Use Win+Alt+<arrow-keys> to move current active window around. So I come up with Autohotkey script:
WinMoveRelative(rx, ry)
{
; Move current window by a relative rx, ry value. rx, ry can be positive or negative
WinGetPos, x, y, width, height, A
absx := x + rx
absy := y + ry
WinMove, A, , %absx%, %absy%
}
;
g_moveunit := 20
!#Left:: WinMoveRelative(0-%g_moveunit%, 0) ; DON'T WORK
!#Right:: WinMoveRelative(%g_moveunit%, 0) ; DON'T WORK
!#Up:: WinMoveRelative(0, -20) ; works
!#Down:: WinMoveRelative(0, 20) ; works
I just can't figure out how to pass g_moveunit
and its negative value to the function. Please help.
Autohotkey v1.1.13.01
%
); it's an expression! Rule of thumb: When working with pure numbers or passing something to a function, it's an expression.g_moveunit:=20
has to appear before any hotkey definition, otherwise,g_moveunit
will always be empty value.