antmar904

Close GUI after x amount of time

3 posts in this topic

#1 ·  Posted (edited)

Hi all,

I have a GUI displaying a message and I would like the GUI to close and exit after 5 seconds but this does not seem to work.

When I start the GUI the message box appears right away.

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


Local $iTimmer = TimerInit()
Local $iTimmerDuration = 5000 ;5 sec



#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Label1 = GUICtrlCreateLabel("Label1", 152, 168, 86, 36)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case TimerDiff($iTimmer) >= $iTimmerDuration
                MsgBox(0, "Times up", "Idle time limit reached")
                Exit
    EndSwitch
WEnd

 

Edited by antmar904

Share this post


Link to post
Share on other sites



Don't use the Case as that is for the returned msg from the gui. something like this?:

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


Local $iTimmer = TimerInit()
Local $iTimmerDuration = 5000 ;5 sec



#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Label1 = GUICtrlCreateLabel("Label1", 152, 168, 86, 36)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If TimerDiff($iTimmer) >= $iTimmerDuration Then
        GUIDelete($Form1)
        MsgBox(0, "Times up", "Idle time limit reached")
        Exit
    EndIf
WEnd

Jos


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

Share this post


Link to post
Share on other sites

@Jos

 

Yes thank you that worked!

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