 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Tsincaat Guest
|
Posted: Mon Mar 31, 2008 4:33 am Post subject: Setting variables with a GUI |
|
|
I want to be able to use the edit box to set a variable, I'm wondering how to do this
Here's my example script right now:
| Code: |
Variable1= 10000
Variable2= 30000
Gui, Font, S10 CDefault, Verdana
Gui, Add, Button, x376 y112 w100 h30 , Exit
Gui, Add, Button, x266 y112 w100 h30 , Start
Gui, Add, Text, x156 y52 w100 h30 , Description1
Gui, Add, Text, x266 y52 w100 h30 , Description2
Gui, Add, Edit, x156 y82 w100 h30 , %Variable1%
Gui, Add, Text, x376 y52 w100 h30 , Description3
Gui, Add, Edit, x266 y82 w100 h30 , %Variable2%
Gui, Add, Edit, x376 y82 w100 h30 ,
Gui, Show, x308 y363 h152 w485, New GUI Window
Return
GuiClose:
ExitApp
ButtonExit:
ExitApp
ButtonStart:
msgbox Variable1 is %Variable1% |
Right now I can edit what is in the boxes, but it won't be saved. |
|
| Back to top |
|
 |
Klaus
Joined: 12 May 2005 Posts: 205 Location: Münster, Germany
|
Posted: Mon Mar 31, 2008 5:00 am Post subject: |
|
|
Hi, Tsincaat,
have a look at my corrections: | Code: | Variable1= 10000
Variable2= 30000
Gui, Font, S10 CDefault, Verdana
Gui, Add, Button, x376 y112 w100 h30 , Exit
Gui, Add, Button, x266 y112 w100 h30 , Start
Gui, Add, Text, x156 y52 w100 h30 , Description1
Gui, Add, Text, x266 y52 w100 h30 , Description2
Gui, Add, Edit, x156 y82 w100 h30 vedit1 , %Variable1%
Gui, Add, Text, x376 y52 w100 h30 , Description3
Gui, Add, Edit, x266 y82 w100 h30 , %Variable2%
Gui, Add, Edit, x376 y82 w100 h30 ,
Gui, Show, x308 y363 h152 w485, New GUI Window
Return
GuiClose:
ExitApp
ButtonExit:
ExitApp
ButtonStart:
Gui, Submit, Nohide ; NEW
msgbox Variable1 is %Variable1% ; your original code
msgbox, %edit1% ; NEW
return ; NEW |
In your original code you display at the label ButtonStart the content of the variable Variable1, not the content of the edit control. I inserted a variable definition for that edit control "vedit1". Don't forget the "Gui, Submit, Nohide" before working with the edit control's variable. And don't forget the "return" at the end of a label's code.
Hope I could help,
Klaus |
|
| Back to top |
|
 |
kumpel100
Joined: 22 Mar 2008 Posts: 7
|
Posted: Mon Mar 31, 2008 2:49 pm Post subject: |
|
|
how do i set then:
%edit1% to this %Variable1% back?
i have nearly same problem with mine script.
my example is:
Gui, Add, Edit, x196 y110 w40 h17 vinput13, %StamHeal_Hotk%
SetStamHealHK:
Gui, Submit, NoHide
MsgBox,,, Stamhotkey = %input13% ,1
MsgBox,,, Stamhotkey1 = %StamHeal_Hotk% ,1
Gosub Save
return
when i change my hotkey the new variable is %input13%
but my whole script part is using %StamHeal_Hotk%
can i also set a new variable from %input13% to %StamHeal_Hotk% ?? |
|
| Back to top |
|
 |
Icarus
Joined: 24 Nov 2005 Posts: 507
|
Posted: Mon Mar 31, 2008 3:06 pm Post subject: |
|
|
1. You may use the same variable for input, as the one that you display, as in Gui, Add, Edit, vVariable1, %Variable1%
2. You may use AHK's assignment as always (variable1:=edit1)
I have created a shorter test script, see if this explains it:
| Code: | #SingleInstance Force
Variable1 = 10000
Gui, Add, Edit, w200 vVariable1 center, %Variable1%
Gui, Add, Button ,wp gButtonStart, Submit
Gui, Add, Button ,wp gButtonCancel, Cancel
Gui, Show,, New GUI Window
Return
GuiClose:
GuiEscape:
ExitApp
Return
ButtonStart:
Gui, Submit, Nohide
MsgBox Variable1 was modified and is now [%Variable1%]
Return
ButtonCancel:
MsgBox Variable1 was not modified and is still [%Variable1%]
Return |
|
|
| Back to top |
|
 |
kumpel100
Joined: 22 Mar 2008 Posts: 7
|
Posted: Mon Mar 31, 2008 3:22 pm Post subject: |
|
|
bah yes that help me alot thx, sir  |
|
| 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
|