Naveed 0 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 Share this post Link to post Share on other sites
Yoriz 6 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 1 WIHedgehog reacted to this 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. Share this post Link to post Share on other sites