Sets the delay that will occur after each mouse movement or click.
PrevDelay := SetMouseDelay(Delay , "Play")
Type: Integer
Time in milliseconds. Specify -1 for no delay at all or 0 for the smallest possible delay (however, if the Play parameter is present, both 0 and -1 produce no delay).
Type: String
If blank or omitted, the delay is applied to the traditional SendEvent mode. Otherwise, specify the word Play to apply the delay to the SendPlay mode. If a script never uses this parameter, the delay is always -1 for SendPlay.
Type: Integer
This function returns the previous setting.
By default, for the traditional SendEvent mode, a short delay (sleep) of 10 milliseconds is done automatically after every mouse movement or click generated by Click, MouseMove, MouseClick, and MouseClickDrag. This is done to improve the reliability of scripts because a window sometimes can't keep up with a rapid flood of mouse events. For SendPlay mode, the default delay is -1.
SetMouseDelay is not obeyed when using SendInput mode (which is the default); there is no delay between mouse movements or clicks in that mode.
Due to the granularity of the OS's time-keeping system, delays might be rounded up to the nearest multiple of 10 or 15.
For SendEvent mode, a delay of 0 internally executes a Sleep(0), which yields the remainder of the script's timeslice to any other process that may need it. If there is none, Sleep(0) will not sleep at all. By contrast, a delay of -1 will never sleep.
The built-in variable A_MouseDelay contains the current setting for SendEvent mode, while A_MouseDelayPlay contains the current setting for SendPlay mode. They can also be assigned a new value instead of calling SetMouseDelay.
Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this function. That default may be changed by using this function during script startup.
SetDefaultMouseSpeed, Click, MouseMove, MouseClick, MouseClickDrag, SendMode, SetKeyDelay, SetControlDelay, SetWinDelay