Kasteel 0 Posted August 15, 2011 Hi How can I stop / exit my script after 5 min? Would like the rest of the script to run stuff during the 5 min though. But needs to exit when 5 min is reached. Would appreciate any help Share this post Link to post Share on other sites
enaiman 16 Posted August 15, 2011 Several ways - easiest one: use AdlibRegister and TimerInit and TimerDiff Use TimerInit at the beginig of the script and use TimerDiff inside the function called by AdLib - if the value returned by TimerDiff is greater than 1000*60*5 then exit. The function is called automatically every 250ms by default so you don't need to worry. Have a look at the examples in the help file. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example scriptwannabe "Unbeatable" Tic-Tac-ToePaper-Scissor-Rock ... try to beat it anyway :) Share this post Link to post Share on other sites
Kasteel 0 Posted August 15, 2011 HiHow can I stop / exit my script after 5 min? Would like the rest of the script to run stuff during the 5 min though.But needs to exit when 5 min is reached.Would appreciate any help Thanks Share this post Link to post Share on other sites
Spiff59 54 Posted August 16, 2011 _Timer_SetTimer() also works nicely, with pretty much just one line of code. #include <Timers.au3> $hWnd = GUICreate("", 200, 120) $hTimer = _Timer_SetTimer($hWnd, 5000, "_Exit", -1) GUISetState(@SW_SHOW) ;------------------------------------------------------------------------------- While 1 If GUIGetMsg() = -3 Then ExitLoop WEnd Exit ;------------------------------------------------------------------------------- Func _Exit($hWnd, $iMsg, $iwParam, $ilParam) Beep(800,50) Exit EndFunc Share this post Link to post Share on other sites
PowerCat 0 Posted August 16, 2011 Will the adlib function run even if there's a script blocking function running, such as a msgbox? Or is it only effective in the case of loops running? Share this post Link to post Share on other sites
enaiman 16 Posted August 17, 2011 Yeah, it's much easier to use _Timer_SetTimer - go for that. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example scriptwannabe "Unbeatable" Tic-Tac-ToePaper-Scissor-Rock ... try to beat it anyway :) Share this post Link to post Share on other sites