antmar904 Posted August 18, 2016 Share Posted August 18, 2016 (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 August 18, 2016 by antmar904 Link to comment Share on other sites More sharing options...
Developers Jos Posted August 18, 2016 Developers Share Posted August 18, 2016 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 More sharing options...
antmar904 Posted August 18, 2016 Author Share Posted August 18, 2016 @Jos Yes thank you that worked! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now