SetControlDelay

Sets the delay that will occur after each control-modifying function.

SetControlDelay Delay

Parameters

Delay

Type: Integer

Time in milliseconds. Specify -1 for no delay at all or 0 for the smallest possible delay.

Return Value

Type: Integer

This function returns the previous setting.

Remarks

If SetControlDelay is not used, the default delay is 20.

A short delay (sleep) is done automatically after every Control function that changes a control. This is done to improve the reliability of scripts because a control sometimes needs a period of "rest" after being changed by one of these functions, so that the control has a chance to update itself and respond to the next function that the script may attempt to send to it.

Specifically, SetControlDelay affects the following functions: ControlAddItem, ControlChooseIndex, ControlChooseString, ControlClick, ControlDeleteItem, EditPaste, ControlFindItem, ControlFocus, ControlHide, ControlHideDropDown, ControlMove, ControlSetChecked, ControlSetEnabled, ControlSetText, ControlShow, ControlShowDropDown.

ControlSend is not affected; it uses SetKeyDelay.

Although a delay of -1 (no delay at all) is allowed, it is recommended that at least 0 be used, to increase confidence that the script will run correctly even when the CPU is under load.

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.

If the CPU is slow or under load, or if window animation is enabled, higher delay values may be needed.

The built-in variable A_ControlDelay contains the current setting and can also be assigned a new value instead of calling SetControlDelay.

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.

Control functions, SetWinDelay, SetKeyDelay, SetMouseDelay

Examples

Causes the smallest possible delay to occur after each control-modifying function.

SetControlDelay 0