Sign in to follow this  
Followers 0
DoctorSLO

Noob Question - GUI to variable

7 posts in this topic

#1 ·  Posted (edited)

Hi

I'm beginner in autoit.

Here is my example script:

#include <GUIConstantsEx.au3>

GUICreate("Hello World", 500, 100)
$Input = GUICtrlCreateInput("input here", 10, 10)
$Button = GUICtrlCreateButton("OK", 250, 10)
GUISetState(@SW_SHOW)

Local $Sleep

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $Button
        $Input = $Sleep //this is not correct
    EndSelect
WEnd

Sleep($Sleep)
//And more code following ....

Now I know this is wrong, I'm asking you how to do it correct. I want that the number I entered in Input set the $Sleep variable. I do this like this $Input = $Sleep, but something is missing, plz help ... thx

And I also need that GUI interface close when Sleep variable is set.

Edited by DoctorSLO

Share this post


Link to post
Share on other sites



Look at GUICtrlRead


Best Regards BugFix  

Share this post


Link to post
Share on other sites

Welcome to the forum! :)

Use a GuiCtrlRead function to get a data of the control.

#include <GUIConstantsEx.au3>

GUICreate("Hello World", 500, 100)
$Input = GUICtrlCreateInput("input here", 10, 10)
$Button = GUICtrlCreateButton("OK", 250, 10)
GUISetState(@SW_SHOW)

Local $Sleep

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $Button
        $Sleep = GUICtrlRead($Input)
        MsgBox(0, "Sleep", $Sleep)
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

Thank you, I do it. I just want to know how to close GUI when I press OK button on msgbox that appeared. I put $GUI_EVENT_CLOSE but its not work :)

And also the MsgBox(0, "Title", "here we go") its not show up :lmao: . I must put it in while or function ?

#include <GUIConstantsEx.au3>

GUICreate("Hello World", 500, 100)
$Input = GUICtrlCreateInput("input here", 10, 10)
$Button = GUICtrlCreateButton("OK", 250, 10)
GUISetState(@SW_SHOW)

Local $Sleep

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $Button
        $Sleep = GUICtrlRead($Input)
        MsgBox(0, "ok", "Sleep time is " & $Sleep)
    EndSelect
WEnd

Sleep($Sleep)
MsgBox(0, "Title", "here we go")

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thx, now its working fine. To close GUI Window I used GUISetState(@SW_HIDE). So now looks like this :

#include <GUIConstantsEx.au3>

GUICreate("Hello World", 500, 100)
$Input = GUICtrlCreateInput("input here", 10, 10)
$Button = GUICtrlCreateButton("OK", 250, 10)
GUISetState(@SW_SHOW)

Local $Sleep

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $Button
        GUISetState(@SW_HIDE)
        $Sleep = GUICtrlRead($Input)
        MsgBox(0, "ok", "Sleep time is " & $Sleep)
        ExitLoop
    EndSelect
WEnd


Sleep($Sleep)
MsgBox(0, "Title", "here we go")

Thx

Edited by DoctorSLO

Share this post


Link to post
Share on other sites

Normally you would delete the GUI unless you want to display it again at a later stage or still need to read the content of any of the Controls:

$Sleep = GUICtrlRead($Input)
        MsgBox(0, "ok", "Sleep time is " & $Sleep)
        GUIDelete()
        ExitLoop

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0