boji Posted April 11, 2008 Share Posted April 11, 2008 (edited) . Edited April 14, 2008 by boji Link to comment Share on other sites More sharing options...
Bert Posted April 11, 2008 Share Posted April 11, 2008 You have no way of exiting the loop. $start=TimerInit() $diff = TimerDiff($start) $f = 1 $z =($diff <= $f) HotKeySet("{ESC}", "Terminate") While(1) sleep(100) If $z = 1 then open_custsrch() If $z = 0 then MsgBox(4096, "Tool", "Timed out", 10) Exit EndIf WEnd Func open_custsrch() ;program with multiple steps that takes time to run through (lots of waitwinactive) End Func Func Terminate() Exit End Func The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
boji Posted April 11, 2008 Author Share Posted April 11, 2008 Thank you for the help. However this does not stop program before 3 seconds is up. I'm not sure how to stop a function from running while is has been activated by an 'if' statment. Any other help would be much appriciated. Thanks. $start=TimerInit() $diff = TimerDiff($start) $f = 2 $z =($diff <= $f) HotKeySet("{ESC}", "Terminate") While(1) sleep(100) If $z = 1 then open_custsrch() If $z = 0 then MsgBox(4096, "Tool", "Timed out", 10) Exit EndIf WEnd Func open_custsrch() Sleep(3000) MsgBox(4096, "Tool", "Ran 3 seconds", 10) Exit EndFunc Func Terminate() Exit 0 EndFunc Link to comment Share on other sites More sharing options...
boji Posted April 14, 2008 Author Share Posted April 14, 2008 Just a small bump here. Curious to know if there is a way to kill a function mid execute, if say, a set time is exceeded. Link to comment Share on other sites More sharing options...
someone Posted April 14, 2008 Share Posted April 14, 2008 (edited) Probably the best thing to do in this situation is to use AdlibEnable(). You have to keep in the back of your head that Autoit is not a multi-threaded language; it only does one thing at a time. Truthfully in my opinion this is less of an issue that it would usually seem, as often you can change your logic in how you code, and still get what you need. I'm certainly not an experienced programmer, so I'm sure people feel differently, but I've always been able to do what I need to with Autoit. EDIT: I should add I am not 100% sure that adlib, or anything will work all the time in every situation. I don't want to come off as definite(definite for, or against a solution) when I'm not. Edited April 14, 2008 by someone While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
boji Posted April 17, 2008 Author Share Posted April 17, 2008 (edited) Thank you for your response. Ill play with adlib() and see what I can get. If there is a way to get autoit to "auto close" after a time, regardless of the line the code the .exe is presently on, that would be most benificial. I need a "safty hatch" if my program hangs from errant user input. AdlibEnable("killprog",2000) func killprog() exit endfunc looks like it might just do the trick. Thank you. Edited April 17, 2008 by boji 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