Sign in to follow this  
Followers 0
Rydextillxixdiex

More accurate SLEEP?

8 posts in this topic

Is there a more time accurate way to pause your scripts as Sleep is in fact very inaccurate to the point where it is sometimes five seconds off.


...will never learn all there is to know about autoit, no worries...i came to the forums :)

Share this post


Link to post
Share on other sites



_Timer_Init and _Timer_Diff

(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

From what the help file expresses, these are timer functions. They just "count" time and is capable of displaying it in a tooltip, can this be used in a similar way as sleep can? Sorry but help file was no help here please explain more.


...will never learn all there is to know about autoit, no worries...i came to the forums :)

Share this post


Link to post
Share on other sites

What do you mean that sleep is inaccurate? I'm sure that the function calls the sleep command through Windows threading.

Even if that is wrong, I have never seen sleep do that. Have you tested different versions of AutoIt and/or different computers? Maybe you have a bad install or bad system.

Share this post


Link to post
Share on other sites

IMO "sleep" is accurate. If you don't want to use any sleep - then you can always use _Timer_Init and _Timer_Diff at the cost of CPU performance.

#Include <Timers.au3>
$start = _Timer_Init()
Do 
    $end = _Timer_Diff($start)
Until $end > 5000
MsgBox(0, "Time", "Elapsed Time: "&$end)

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

Is there a more time accurate way to pause your scripts as Sleep is in fact very inaccurate to the point where it is sometimes five seconds off.

According to Ludocos thread HERE Sleep() should not be off more than around 10ms, there must be some seriously problems with your computers if it's five seconds!!

Share this post


Link to post
Share on other sites

Looking at some of your previous posts it looks like you're automating a game, which are generally CPU intensive, so Windows might not be giving your script the CPU time it needs. Try increasing the priority of the script with ProcessSetPriority()

ProcessSetPriority(@AutoItPID,4)

That should set the priority of the script to High.

Share this post


Link to post
Share on other sites

Your right i often am, and thanks for your time i will test this.


...will never learn all there is to know about autoit, no worries...i came to the forums :)

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