skysel Posted December 10, 2008 Share 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? Link to comment Share on other sites More sharing options...
Andreik Posted December 10, 2008 Share 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 ( ). When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 10, 2008 Moderators Share 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. Link to comment Share on other sites More sharing options...
Andreik Posted December 10, 2008 Share 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 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
skysel Posted December 10, 2008 Author Share 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. 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