Naveed Posted July 30, 2010 Posted July 30, 2010 Hi, I have a bit of a situation with my GUI, i need to automatically close the GUI after a period of inactivity lets say 15 minutes of not being used?? Is this possible? Thanks Nav
Yoriz Posted July 30, 2010 Posted July 30, 2010 Hi, Here is a way of doing it, have a TimerInit() before the start of the windows msg loop, check for it reaching a idle maximum duration as one of the cases, after any other case reset the timmer. i made a little example that has two button that will reset the timmer and a status to show the idle time in seconds. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> _Form1() Func _Form1() #Region ### START Koda GUI section ### Form= Local $Form1 = GUICreate("Form1", 196, 94, -1, -1) Local $hButton1 = GUICtrlCreateButton("Button1", 20, 24, 75, 25) Local $hButton2 = GUICtrlCreateButton("Button2", 100, 24, 75, 25) Local $hStatusBar1 = _GUICtrlStatusBar_Create($Form1) _GUICtrlStatusBar_SetSimple($hStatusBar1) _GUICtrlStatusBar_SetText($hStatusBar1, "Idle Time: ") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $iTimmer = TimerInit() Local $iTimmerDuraction = 20000 Local $sStatusText While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $hButton1 MsgBox(0, "Button1", "Idle timmer reset") $iTimmer = TimerInit() Case $nMsg = $hButton2 MsgBox(0, "Button2", "Idle timmer reset") $iTimmer = TimerInit() Case TimerDiff($iTimmer) >= $iTimmerDuraction MsgBox(0, "Times up", "Idle time limit reached") ExitLoop Case Else Local $sNewTimeText = "Idle Time: " & Round(TimerDiff($iTimmer) / 1000) If $sStatusText <> $sNewTimeText Then $sStatusText = $sNewTimeText _GUICtrlStatusBar_SetText($hStatusBar1, $sStatusText) EndIf EndSelect WEnd EndFunc ;==>_Form1 WIHedgehog 1 GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
AutoDEV Posted November 25, 2023 Posted November 25, 2023 New code. i have test and is ok. But how to exit a GUI after 10s. In this code, when countdown is finish all close ! THX
argumentum Posted November 26, 2023 Posted November 26, 2023 (edited) replace Exit with Return GUIDelete($Form1). Have fun PS: you know that you'll need to return to your own loop in your code right ? PSS: no, I can not give you an example. PSSS: open a new thread next time. Reviving old ones is frown upon. Edited November 26, 2023 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
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