To keep it simple by not using a function, but longer code, this is what you could do. I think it's easier to understand the long-form code and then seeing how it gets condensed with a function.
Code: Select all
Numpad1::
MouseGetPos, X, Y
MouseMove, 0, -90, , R
Click
MouseMove, %X%, %Y%
return
Numpad2::
MouseGetPos, X, Y
MouseMove, 20, -90, , R
Click
MouseMove, %X%, %Y%
return
By using a function like KuroiLight does there, you assign values to variable defined in the function.
RelativeClick(rX := 0, rY := 0){ means the function name is RelativeClick (it can be almost any name you want), the first parameter is rX, and the second parameter is rY. You can use rX and rY as variables inside the function. The := 0 gives a default value to rX and rY -- that is, if you do not explicitly fill in that parameter when you call the function, it will use 0 there. Which means in KuroiLight's code, instead of
Numpad1::RelativeClick(0, -90) (which calls the function; this is not the definition because the { is not there), you could actually use
Numpad1::RelativeClick( , -90). The blank value for the first parameter would be treated as a 0 by the definition of the function.
And KuroiLight is using the variables rX and rY in the MouseMove command because that is what you are changing between the Numpad1 and Numpad2 hotkeys.