By using this site you agree to the use of cookies.

Learn more

Share via:

AutoIt Sleep Function

The sleep function can be used to pause the execution of scripts.

Edited: 2017-12-19 17:54

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 repeatedly call sleep within a loop.

Sometimes you might run into systems with anti-automation measures that are intended to prevent scripts from using (or abusing) the system. Some of these can be avoided by using sleep in combination with random to make your script behave more human-like. Often, just using a sleep alone will be enough to avoid CAPTCHAs.

Reminder. 1000 milliseconds equals 1 second.

Sleep for 10 seconds, and continue running the script:


Using the sleep function

The below script will pause for 10 seconds, before clicking a given spot on the screen.

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


DelayAmount of time to pause in milliseconds.