Jump to content

Close GUI after x amount of time


antmar904
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...