 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
koliber Guest
|
Posted: Thu Mar 18, 2010 8:32 pm Post subject: set global variables from functions |
|
|
hi,
I want to set variables in global scope in function body.
But MX and MY show nothing.
Any help?
MButton::
Starter()
return
Starter()
{
GetCoords()
MsgBox %MX% %MY%
}
GetCoords()
{
global MX, MY
MouseClick, left, 496, 338
MouseGetPos, MX, MY
Sleep, 100
} |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Thu Mar 18, 2010 8:42 pm Post subject: |
|
|
Specifying the two variables as global in one function has no bearing on how the other function treats those variables. It cannot access them unless 1) the variables are passed to the function, or 2) the function is declared global:
| Code: | F7::Starter()
Starter() {
global
GetCoords()
MsgBox %MX% %MY%
return
}
GetCoords() {
global MX, MY
MouseGetPos, MX, MY
Sleep, 100
return
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
koliber Guest
|
Posted: Thu Mar 18, 2010 8:49 pm Post subject: |
|
|
Thx
| sinkfaze wrote: | Specifying the two variables as global in one function has no bearing on how the other function treats those variables. It cannot access them unless 1) the variables are passed to the function, or 2) the function is declared global:
|
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|