AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

set global variables from functions

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
koliber
Guest





PostPosted: Thu Mar 18, 2010 8:32 pm    Post subject: set global variables from functions Reply with quote

hi,

I want to set variables in global scope in function body.
But MX and MY show nothing.
Any help? Smile


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)

PostPosted: Thu Mar 18, 2010 8:42 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
koliber
Guest





PostPosted: Thu Mar 18, 2010 8:49 pm    Post subject: Reply with quote

Thx Very Happy

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
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group