Gui, Submit not working Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
seedsensation
Posts: 1
Joined: 07 Dec 2021, 11:21

Gui, Submit not working

Post by seedsensation » 07 Dec 2021, 11:27

Hi,

I'm trying to write a piece of code that has a GUI window with a text entry box and a slider. The text entry box changes what text is returned, and the slider changes the size of the text. However, when I run this code, the Gui, Submit code doesn't work - all of the variables that the documentation says should be updated aren't, and remain empty.

Code: Select all

!m::
Gui, Add, Text,, Please enter your text:
Gui, Add, Edit, r2 vmytext w135
Gui, Add, Slider, vmyslider gUpdateSize, 25
Gui, Add, Text, vtextsize, Text Size
Gui, Add, Button, Default w80 gSubmit, OK
Gui, +AlwaysOnTop +Owner
Gui, Show


Return

UpdateSize() {
Gui +LastFound
Gui, Submit, nohide
MsgBox, %myslider%
Gui, Font, s%myslider%
GuiControl, Font, textsize
}

Submit() {
SendLevel 1
Completed := True
Gui, Submit, nohide
Gui, Destroy
MsgBox, %mytext%
BounceText(mytext,myslider)

}
ty for the help :+)

User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: Gui, Submit not working  Topic is solved

Post by mikeyww » 07 Dec 2021, 11:53

Variables are local to functions by default. If you want to use a variable globally, such as inside a function, then declare it as a global variable, or pass it to the function as a parameter. An easy approach to your script is to use a labeled subroutine instead of a function.

Code: Select all

Gui, +AlwaysOnTop
Gui, Add, Text,, Please enter your text:
Gui, Add, Edit, r2 vmytext w135
Gui, Add, Slider, vmyslider gUpdateSize, 25
Gui, Add, Text, w100 h100 vtextsize, Text Size
Gui, Add, Button, Default w80, OK

!m::
Gui, Show, x200 y200
UpdateSize:
Gui, Submit, NoHide
Gui, Font, s%myslider%
GuiControl, Font, textsize
Return

ButtonOK:
Gui, Submit
MsgBox, %mytext%
Return

Post Reply

Return to “Ask for Help (v1)”