SetBatchLines

Determines how fast a script will run (affects CPU utilization).

SetBatchLines, Milliseconds
SetBatchLines, LineCount

Parameters

Milliseconds

An integer immediately followed by "ms" to specify how often the script should sleep (each sleep is 10 ms long). In the following example, the script will sleep for 10 ms every time it has run for 20 ms: SetBatchLines, 20ms.

LineCount

The number of script lines to execute prior to sleeping for 10 ms. The value can be as high as 9223372036854775807. Also, this mode is mutually exclusive of the Milliseconds mode in the previous paragraph; that is, only one of them can be in effect at a time.

Remarks

If SetBatchLines is not used, the default setting is 10ms, except in versions prior to [v1.0.16], which use 10 (lines) instead.

Use SetBatchLines -1 to never sleep (i.e. have the script run at maximum speed).

The Milliseconds mode is recommended for scripts whenever speed and cooperation are important. For example, on most systems a setting of 10ms will prevent the script from using any more than 50 % of an idle CPU's time. This allows scripts to run quickly while still maintaining a high level of cooperation with CPU sensitive tasks such as games and video capture/playback.

The built-in variable A_BatchLines contains the current setting.

The speed of a script can also be impacted by the following commands, depending on the nature of the script: SetWinDelay, SetControlDelay, SendMode, SetKeyDelay, SetMouseDelay, and SetDefaultMouseSpeed.

Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).

SetWinDelay, SetControlDelay, SendMode, SetKeyDelay, SetMouseDelay, SetDefaultMouseSpeed, Critical

Examples

Causes the script to sleep every 10 ms.

SetBatchLines, 10ms

Causes the script to sleep every 1000 lines.

SetBatchLines, 1000