AutoHotkey – Sleep

Waits until the next line will be executed. The time unit is in milliseconds (ms). E.g.: 200 ms -> 0,2 sec

Parameters

Sleep, Delay

  • Delay: the specified amount of time, can be an expression

Examples

Wait for a fixed, static delay.

MsgBox, % "Wait for 2 s."
Sleep, 2000
MsgBox % "Press Enter to return"
Sleep, variable & expression
Delay := 333
Sleep, % Delay
; or Sleep, %Delay%
Random sleep
; test random sleeps 3 times
Loop 3
{
  Started := A_TickCount
  Random, RandomSleep, 200, 1000
  Sleep, % RandomSleep
  MsgBox, % Out .= A_index ". lasted " A_TickCount-Started " ms.`n"
}