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 

Getting a Gui Variable Value in a Function

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



Joined: 20 Dec 2007
Posts: 22

PostPosted: Mon Jan 18, 2010 7:10 pm    Post subject: Getting a Gui Variable Value in a Function Reply with quote

I know I must be missing something simple, but how do I get the variable QuoteText to showup in the function's message box?

Code:
gui, Add, Text, x16 y13 w190 h220 vQuoteText +Smooth +VScroll +BackgroundTrans +BS_MULTILINE ,
gui, show, x100 y100 w220 h250
GuiControl, , QuoteText, "Happy Days are likely Ahead"
Return

ShowStuff(num1, num2)
{
global
msgbox, %num1% and %num2%
msgbox, %QuoteText%
}
return

F1::
Showstuff(4, 5)
return


Why doesn't this work?
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5044
Location: the tunnel(?=light)

PostPosted: Mon Jan 18, 2010 7:21 pm    Post subject: Reply with quote

For one thing you didn't submit the GUI:

Code:
Gui, Add, Text, x16 y13 w190 h220 vQuoteText +Smooth +VScroll +BackgroundTrans +BS_MULTILINE ,
Gui, show, x100 y100 w220 h250
GuiControl, , QuoteText, "Happy Days are likely Ahead"
Return

ShowStuff(num1, num2)
{
global
msgbox, %num1% and %num2%
msgbox, %QuoteText%
}
return

F1::
Gui, Submit
Showstuff(4, 5)
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
rockum



Joined: 20 Dec 2007
Posts: 22

PostPosted: Mon Jan 18, 2010 7:36 pm    Post subject: Reply with quote

It still doesn't seem to work, but thank you for pointing out one of the problems in the script.
Back to top
View user's profile Send private message
MasterFocus



Joined: 08 Apr 2009
Posts: 3035
Location: Rio de Janeiro - RJ - Brasil

PostPosted: Mon Jan 18, 2010 8:38 pm    Post subject: Reply with quote

EDIT: Nevermind, sinkfaze's following post provides the solution.
_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"

Antonio França
My stuff: Google Profile


Last edited by MasterFocus on Mon Jan 18, 2010 8:42 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
sinkfaze



Joined: 18 Mar 2008
Posts: 5044
Location: the tunnel(?=light)

PostPosted: Mon Jan 18, 2010 8:40 pm    Post subject: Reply with quote

My apologies, to get the text of a Text control you must use GuiControlGet:

GuiControlGet - ControlID wrote:
If the target control has an associated variable, specify the variable's name as the ControlID (this method takes precedence over the ones described next). For this reason, it is usually best to assign a variable to any control that will later be accessed via GuiControl or GuiControlGet, even if that control is not input-capable (such as GroupBox or Text).


Code:
Gui, Add, Text, x16 y13 w190 h220 vQuoteText +Smooth +VScroll +BackgroundTrans +BS_MULTILINE ,
Gui, show, x100 y100 w220 h250
GuiControl, , QuoteText, "Happy Days are likely Ahead"
Return

ShowStuff(num1, num2)
{
global
msgbox, %num1% and %num2%
msgbox, %QuoteText%
}
return

F1::
Gui, Submit
GuiControlGet, QuoteText, , QuoteText, Text
Showstuff(4, 5)
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
rockum



Joined: 20 Dec 2007
Posts: 22

PostPosted: Mon Jan 18, 2010 8:46 pm    Post subject: Reply with quote

Thank works. Thanks guys.
Back to top
View user's profile Send private message
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