#MaxThreads

Sets the maximum number of simultaneous threads.

#MaxThreads Value

Parameters

Value

Type: Integer

The maximum total number of threads that can exist simultaneously. Specifying a number higher than 255 is the same as specifying 255.

Remarks

If this directive is unspecified in the script, it will behave as though set to 10.

This setting is global, meaning that it needs to be specified only once (anywhere in the script) to affect the behavior of the entire script.

Although a value of 1 is allowed, it is not recommended because it would prevent new hotkeys from launching whenever the script is displaying a message box or other dialog. It would also prevent timers from running whenever another thread is sleeping or waiting.

The OnExit callback function will always launch regardless of how many threads exist.

If this setting is lower than #MaxThreadsPerHotkey, it effectively overrides that setting.

Like other directives, #MaxThreads cannot be executed conditionally.

#MaxThreadsPerHotkey, Threads, A_MaxHotkeysPerInterval, ListHotkeys

Examples

Allows a maximum of 2 instead of 10 simultaneous threads.

#MaxThreads 2