Jump to content
Sign in to follow this  
xah

GUI timeout

Recommended Posts

xah

I want to set a timeout for the GUI, but I can't get it to work.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Timers.au3>

Local $doorgaan, $overslaan, $msg

$hGUI = GUICreate("AH-Tool", 190, 85)
GUISetStyle(BitOR($WS_CAPTION, $WS_POPUPWINDOW) )

GUICtrlCreateLabel("LOT01101", 10, 10)
$doorgaan = GUICtrlCreateButton("Doorgaan", 10, 30, 80, 20)
$overslaan = GUICtrlCreateButton("Overslaan", 100, 30, 80, 20)

GUISetState() ; display the GUI
_Timer_SetTimer($hGUI, 2000, "Quit"); create timer

While 1
    $msg = GUIGetMsg()
    Sleep(1000)
    Switch $msg
        Case $doorgaan
            GUIDelete()
            MsgBox(0, "Info", "$doorgaan")
            Exit
        Case $overslaan
            GUIDelete()
            MsgBox(0, "Info", "$overslaan")
            Exit
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
    EndSwitch
WEnd

Func Quit()
    Exit
EndFunc

Help please, I just need this GUI to timeout and quit.

Share this post


Link to post
Share on other sites
KaFu

The called func expects params.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Timers.au3>

Local $doorgaan, $overslaan, $msg

$hGUI = GUICreate("AH-Tool", 190, 85)
GUISetStyle(BitOR($WS_CAPTION, $WS_POPUPWINDOW) )

GUICtrlCreateLabel("LOT01101", 10, 10)
$doorgaan = GUICtrlCreateButton("Doorgaan", 10, 30, 80, 20)
$overslaan = GUICtrlCreateButton("Overslaan", 100, 30, 80, 20)

GUISetState() ; display the GUI
_Timer_SetTimer($hGUI, 2000, "Quit")

While 1
    $msg = GUIGetMsg()
    Sleep(10)
    Switch $msg
        Case $doorgaan
            GUIDelete()
            MsgBox(0, "Info", "$doorgaan")
            Exit
        Case $overslaan
            GUIDelete()
            MsgBox(0, "Info", "$overslaan")
            Exit
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
    EndSwitch
WEnd

Func Quit($hWnd, $Msg, $iIDTimer, $dwTime)
    Exit
EndFunc

Share this post


Link to post
Share on other sites
xah

Yes, that's what I was missing. Thanks!

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  

×