gswitzer Posted May 16, 2007 Share Posted May 16, 2007 Hi there all, I'm trying to build a GUI with two click controls, and I'd like it to timeout if a ctrl isn't pressed in 5 minutes. Any ideas or samples of code you could point me to? Thank you! G. Link to comment Share on other sites More sharing options...
Kogmedia Posted May 16, 2007 Share Posted May 16, 2007 (edited) Hi there all, I'm trying to build a GUI with two click controls, and I'd like it to timeout if a ctrl isn't pressed in 5 minutes. Any ideas or samples of code you could point me to? Thank you! G.#include <Date.au3> Global $Secs, $Mins, $Hour, $Time $timer = TimerInit() AdlibEnable("Timer", 50) Func Timer() _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs ) Local $sTime = $Time ; save current time to be able to test and avoid flicker.. $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime <> $Time Then ControlSetText("Timer", "", "Static1", $Time) EndFunc ;==>Timer Here is a timer script If $Mins = 5 then disable control ~Kog~ Edited May 16, 2007 by Kogmedia [font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search Link to comment Share on other sites More sharing options...
Valuater Posted May 16, 2007 Share Posted May 16, 2007 Just what the Doctor ordered...http://www.autoitscript.com/forum/index.ph...st&p=2202018) Link to comment Share on other sites More sharing options...
gswitzer Posted May 16, 2007 Author Share Posted May 16, 2007 Just what the Doctor ordered...http://www.autoitscript.com/forum/index.ph...st&p=2202018)Thanks for the info guys. I'm a little unclear on where to put it into the code though:$AutoUpdater = GUICreate("Updater 3.0", 433, 170, 452, 422,)GUISetIcon("path to ico")GUISetBkColor(0xFFFF00)$Continue = GUICtrlCreateButton("&Continue", 64, 120, 75, 25)$Cancel1 = GUICtrlCreateButton("&Cancel", 271, 121, 75, 25)$Label1 = GUICtrlCreateLabel("Update info", 48, 32, 341, 17)GUISetState(@SW_SHOW)$nMsg = 0While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $Cancel1 Exit Case $nMsg = $Continue ExitLoop EndSelectWEndI tried using the timediff starttimer functions, and I could get it to run the timer for a period of time, but I couldn't get it into the dialog above. Thanks again for the advice. Link to comment Share on other sites More sharing options...
Kogmedia Posted May 16, 2007 Share Posted May 16, 2007 What button do you want to disable? [font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search Link to comment Share on other sites More sharing options...
gswitzer Posted May 16, 2007 Author Share Posted May 16, 2007 I want it to close the dialog completely and continue on with the script. Link to comment Share on other sites More sharing options...
Kogmedia Posted May 16, 2007 Share Posted May 16, 2007 #include <Date.au3> #include <GUIConstants.au3> Global $Secs, $Mins, $Hour, $Time $timer = TimerInit() AdlibEnable("Timer", 50) $AutoUpdater = GUICreate("Updater 3.0", 433, 170, 452, 422) GUISetIcon("path to ico") GUISetBkColor(0xFFFF00) $Continue = GUICtrlCreateButton("&Continue", 64, 120, 75, 25) $Cancel1 = GUICtrlCreateButton("&Cancel", 271, 121, 75, 25) $Label1 = GUICtrlCreateLabel("Update info", 48, 32, 341, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() If $Mins = 5 Then ExitLoop Select Case $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $Cancel1 Exit Case $nMsg = $Continue ExitLoop EndSelect WEnd Func Timer() _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs ) Local $sTime = $Time ; save current time to be able to test and avoid flicker.. $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime <> $Time Then ControlSetText("Timer", "", "Static1", $Time) EndFunc ;==>Timer [font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search Link to comment Share on other sites More sharing options...
gswitzer Posted May 16, 2007 Author Share Posted May 16, 2007 That worked great! Thanks to you, sir, Kogmedia! 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