Sign in to follow this  
Followers 0
boji

Timeout

6 posts in this topic

#1 ·  Posted (edited)

.

Edited by boji

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by someone

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by boji

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0