skysel Posted December 10, 2008 Posted December 10, 2008 I need to know how to give a script some kind of running time limit. So if script hangs and runs more than 30 minutes, it would end itself. Is it possible? _Timer_SetTimer perhaps?
Andreik Posted December 10, 2008 Posted December 10, 2008 I need to know how to give a script some kind of running time limit. So if script hangs and runs more than 30 minutes, it would end itself. Is it possible?_Timer_SetTimer perhaps? TimerInit ( ) and TimerDiff ( ).
Moderators SmOke_N Posted December 10, 2008 Moderators Posted December 10, 2008 I need to know how to give a script some kind of running time limit. So if script hangs and runs more than 30 minutes, it would end itself. Is it possible? _Timer_SetTimer perhaps? Quick and dirty if you're not already using AdlibEnable():Global $i_kill_mins = 30 AdlibEnable("_KillMeTimeIsUp", $i_kill_mins*60*1000) While 1 Sleep(1000000) WEnd Func _KillMeTimeIsUp() MsgBox(16, "Error", "You ran too damn long!", 1) Exit EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Andreik Posted December 10, 2008 Posted December 10, 2008 (edited) This script should exit after 15 sec. Global $TIME_INIT = TimerInit() $EXIT_TIME = 15 AdlibEnable("CheckExit",1000) $GUI = GUICreate("EXAMPLE",300,300) GUISetState(@SW_SHOW) While 1 $MSG = GUIGetMsg() If $MSG = -3 Then Exit Sleep(20) WEnd Func CheckExit() If TimerDiff($TIME_INIT)/1000 >= $EXIT_TIME Then AdlibDisable() Exit EndIf EndFunc Edited December 10, 2008 by Andreik
skysel Posted December 10, 2008 Author Posted December 10, 2008 Quick and dirty if you're not already using AdlibEnable():Global $i_kill_mins = 30 AdlibEnable("_KillMeTimeIsUp", $i_kill_mins*60*1000) While 1 Sleep(1000000) WEnd Func _KillMeTimeIsUp() MsgBox(16, "Error", "You ran too damn long!", 1) Exit EndFunc Thanks for the help! Exactly what I needed.
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