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-03-24 17:11

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.


DelayAmount 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.

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