The AutoIt Sleep function is used to pause scripts for a set amount of time. The sleep function accepts a value in milliseconds, the maximum value is 2147483647 (24 855.1348 days) – If you want the script to pause longer then that, it may be better to create a loop, and repeatedly call sleep from within that loop.
Reminder. 1000 milliseconds equals 1 second.
|Delay||Amount of time to pause in milliseconds.|
AutoIt Sleep Example
The below script will pause for 10 seconds, before clicking a given spot on the screen.
sleep(10000) MouseClick("primary", 200, 150, 5)
To randomize the amount of sleep time we can use the Random function. The below Generates a number between 1000 and 5000, then pauses using the generated number.
sleep(random(1000, 5000, 1)) ; Generates a number between 1000 and 5000