 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
rockum
Joined: 20 Dec 2007 Posts: 22
|
Posted: Mon Jan 18, 2010 7:10 pm Post subject: Getting a Gui Variable Value in a Function |
|
|
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 |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Mon Jan 18, 2010 7:21 pm Post subject: |
|
|
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 |
|
 |
rockum
Joined: 20 Dec 2007 Posts: 22
|
Posted: Mon Jan 18, 2010 7:36 pm Post subject: |
|
|
| It still doesn't seem to work, but thank you for pointing out one of the problems in the script. |
|
| Back to top |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Mon Jan 18, 2010 8:38 pm Post subject: |
|
|
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 |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Mon Jan 18, 2010 8:40 pm Post subject: |
|
|
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 |
|
 |
rockum
Joined: 20 Dec 2007 Posts: 22
|
Posted: Mon Jan 18, 2010 8:46 pm Post subject: |
|
|
| Thank works. Thanks guys. |
|
| 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
|