Jump to content
Sign in to follow this  
Bot

wait for user click the button before doing everything ?

Recommended Posts

Bot

I'm in a For loop and I want to check for user inputs and click the button before doing everything. Can anyone tell me how to do so please ?

$Submit = GUICtrlCreateButton("Submit", 90, 100, 113, 25, 0)

For $i = 5 to 1 Step -1
    $sName = GUICtrlRead ($Name)
    If $sName <> "" Then
    #cs
        If user click the submit button then continue the program or wait until the user click the button.
    #ce
    EndIf
    #cs
        Do something
    #ce
Next

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Bot

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Submit
            ; Do stuff after button is clicked
    EndSwitch
WEnd
Thanks but your code is to let the button do some actions when the user click on it but what I am looking for is to delay the program until the user click the button :) . Anybody please ?

Share this post


Link to post
Share on other sites
Anonymouse

Thanks but your code is to let the button do some actions when the user click on it but what I am looking for is to delay the program until the user click the button :) . Anybody please ?

I don't have enough information in that "example" script... my only solution with that little information would have to be:

If Not $button Then

Do

Sleep(100)

Until

$button

EndIf


children may smile; the wise ponder- Dr. Holmes of Hardvard Medical School on an Ether BingeLove Makes The World Go Round?So does five shots of tequila. What's your point?[quote name='Valik' date='Jun 5 2008, 05:13 PM']wraithdu, 24 hours. Said I have a bad attitude, just driving the point home with a ban.[/quote]This is classic. :)

Share this post


Link to post
Share on other sites
Bot

I have tried but this doesn't work. Can anybody provide me a solution please ?

Share this post


Link to post
Share on other sites
LongBowNZ

Maybe you're looking for something more like this:

#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)

GUICreate("GUI")
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
$Submit = GUICtrlCreateButton("Submit", 5, 5, 100)
GUICtrlSetOnEvent(-1, "Buttonclicked")
GUISetState()

While 1
    Sleep(10)
WEnd

Func Buttonclicked()
    ; Do Stuff
    ConsoleWrite("Button Clicked" & @CRLF)
EndFunc

Func Quit()
    Exit
EndFunc

Share this post


Link to post
Share on other sites
AdmiralAlkex

You could use something like:

Do
Sleep(25)
Until GUIGetMsg() = $Submit

But I got to say I don't understand what good it would do at that place you showed in post#1

Share this post


Link to post
Share on other sites
rasim

Bot

Mayb this be easier?

#include <GuiConstantsEx.au3>

GUICreate("Test", 300, 200)

$input = GUICtrlCreateInput("", 80, 50, 150, 20)

$SubmitButton = GUICtrlCreateButton("Submit", 110, 100, 75, 23)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $SubmitButton
            $InputRead = GUICtrlRead($input)
            If $InputRead <> "" Then
                ;Some action here
                ConsoleWrite($InputRead & @LF)
            EndIf
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Bot

Thank you so much for your answers :) I will test them later :P

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  

×