Using the Image Search Autohotkey Send

SetKeyDelay

Determines the delay that should occur after each key press that is sent via Send or ControlSend.

SetKeyDelay, Delay, PrintDuration, Play

parameter

delay

Time in milliseconds (can be an expression). Use -1 to turn off the delay completely or 0 to have the smallest possible delay (but as soon as the PlayParameter is present, both 0 and -1 produce no delay). Leave this parameter blank for the current delay to maintain.

If SetKeyDelay is never used in the script, traditional SendEvent mode defaults to one delay of 10. The SendPlay mode defaults to one delay from 1. Both modes use one by default Print Duration (see below) from -1.

Print Duration

Certain video games and other specialty applications may require a delay between each key press (between pressing and releasing a key).

Use -1 to turn off the delay completely (the default) or 0 to have the smallest possible delay (but as soon as the PlayParameter is present, both 0 and -1 produce no delay). Leave this parameter blank for the current Print Duration to maintain.

Note: Print Duration also creates a delay after each change of state of a modifier (,, and) in order to be able to support the keys to be sent.

This parameter can be an expression.

Play [v1.0.43 +]

The word Play applies the above settings to SendPlay mode instead of traditional SendEvent mode. If this parameter is never used in the script, SendPlay will always have a delay of -1 / -1.

Remarks

Note: SetKeyDelay has no influence on SendInput; in this mode there is no delay between key presses. The same applies to Send when SendMode Input is active.

There is an automatic short delay (sleep) after every key press that is sent via Send or ControlSend. This delay is necessary to improve the reliability of scripts because there are windows that are quickly overwhelmed by many quick keystrokes.

During the delay (sleep) the current thread is made uninterruptible.

Due to the granularity (inaccuracy) of the time recording in the operating system, delays may be rounded up to the next possible multiple of 10 or 15. For example, a 1 to 10 delay on most Windows XP systems (and likely Windows 2000 as well) is equivalent to 10 or 15.

In Send / SendEvent mode, a delay of 0 internally executes sleep (0). This causes the remaining time slice of the script to be passed to any other process that might need it. If it is not needed by any process, Sleep (0) will not generate sleep at all. A delay of -1, however, will never cause a sleep. For better reliability, 0 is recommended as an alternative to -1.

When the delay is set to -1, a script's process priority has a big impact on how fast it can send keystrokes using traditional SendEvent mode. The priority of a script can be increased with. Although this usually means that keystrokes are sent faster than the active window can process them, the system buffers them automatically. Buffered keystrokes will also arrive in the target window after the Send command has been completed (even if the window is no longer active). This is usually harmless because all subsequent keystrokes that are sent to the same window are placed after the keystrokes that have already been buffered.

The internal variable A_KeyDelay contains the current setting of delay for the Send / SendEvent mode. [v1.1.23 +]:A_KeyDuration contains the current setting of Print Duration, while A_KeyDelayPlay and A_KeyDurationPlay contain the settings for SendPlay.

Each newly started thread (e.g. a hotkey, a user-defined menu item, or a timed subroutine) initially uses the default setting of the command. To change this, the command must be specified in the automatic execution area (at the top of the script).

See also

Send, ControlSend, SendMode, SetMouseDelay, SetControlDelay, SetWinDelay, SetBatchLines, Click

Examples

Causes the smallest possible delay after each button press via Send or ControlSend.

SetKeyDelay, 0