Is there an easier way to assign a VarRef type variable to a global variable?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Gibbons
Posts: 93
Joined: 20 Sep 2016, 20:39

Is there an easier way to assign a VarRef type variable to a global variable?

14 Apr 2023, 21:17

How is the best way to assign the VarRef type variables from MouseGetPos to the global variables of the same name? Is there a more concise way to do it then what I have below:

Code: Select all

xposition := 0
yposition := 0
return  ; end autoexecute section

~LButton::
{
	MouseGetPos &xposition, &yposition
	global xposition := xposition
	global yposition := yposition
}

F5::
{
	MsgBox "Last time you pressed the left mouse button the mouse position was`n`nX: " . xposition . "`nY: " . yposition
}
I'm also trying to wrap my head around the logic behind the whole VarRef concept.
User avatar
boiler
Posts: 17390
Joined: 21 Dec 2014, 02:44

Re: Is there an easier way to assign a VarRef type variable to a global variable?

14 Apr 2023, 21:48

Code: Select all

~LButton::
{
	global
	MouseGetPos &xposition, &yposition
}

If your function had variables you didn’t want declared as global, then you would just declare those two variables as global.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Draken, Rxbie, Vanda_a and 75 guests