Kasteel Posted August 15, 2011 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
enaiman Posted August 15, 2011 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 script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
Kasteel Posted August 15, 2011 Author 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
Spiff59 Posted August 16, 2011 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
PowerCat Posted August 16, 2011 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?
enaiman Posted August 17, 2011 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 script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
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