Jump to content

autoit perfectionism at it's best!


Recommended Posts

@TheAutomator the following script takes about 10ms to run, because of the Sleep(10) instruction so the condition is checked only twice. Also, there is no value from Sleep(1) to Sleep(9) in AutoIt, the minimum is Sleep(10) ms

Local $i = 0, $hTimer = TimerInit()

While $i < 1
    $i += 1

ConsoleWrite(Int(TimerDiff($htimer)) & " ms" & "   i = " & $i & @crlf)

Now, without the Sleep(10) instruction, you'll need (at least) the following equivalent code to run in 10ms :

Local $i = 0, $hTimer = TimerInit()

While $i < 5000
    $i += 1

ConsoleWrite(Int(TimerDiff($htimer)) & " ms" & "   i = " & $i & @crlf)

The condition will have to be checked 5000 times (or 10.000 or more, depending on your computer speed) to exit the loop in 10ms, then CPU heats up.

So the condition was checked only twice in the 1st example and 5.000+ times in the 2nd example, that's a big difference in 10ms !

On 4/20/2022 at 11:40 PM, TheAutomator said:

(read somewhere that sleep even does tiny sleeps with breaks to check for hotkey-presses)

Yes, but those tiny sleeps are all = 10ms (not less when AutoIt Sleep is used) which means that Sleep(100) will call ten times this function :

DllCall("Kernel32.dll", "none", "Sleep", "dword", 10)

Some interesting links below :



Check for the word sleep :

2030        // Set the minimum Sleep accuracy
2031        if (g_oVersion.IsWin9x())
2032            dwMin = 55;
2033        else
2034            dwMin = 10;


Link to comment
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

  • Create New...