Jump to content
Sign in to follow this  
Kasteel

Exit after 5 min

Recommended Posts

Kasteel

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 :mellow:

Share this post


Link to post
Share on other sites
enaiman

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 :)

Share this post


Link to post
Share on other sites
Kasteel

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 :mellow:

Thanks :)

Share this post


Link to post
Share on other sites
Spiff59

_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

Share this post


Link to post
Share on other sites
PowerCat

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?

Share this post


Link to post
Share on other sites
enaiman

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 :)

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  

×