#MaxThreadsPerHotkey - Syntax & Usage | AutoHotkey

AutoHotkey

#MaxThreadsPerHotkey

Sets the maximum number of simultaneous threads per hotkey or hotstring.

#MaxThreadsPerHotkey Value

Parameters

Value

The maximum number of threads that can be launched for a given hotkey/hotstring subroutine (limit 255).

Remarks

This setting is used to control how many "instances" of a given hotkey or hotstring subroutine are allowed to exist simultaneously. For example, if a hotkey has a max of 1 and it is pressed again while its subroutine is already running, the press will be ignored. This is helpful to prevent accidental double-presses. However, if you wish these keypresses to be buffered rather than ignored -- perhaps to increase the responsiveness of the keyboard's auto-repeat feature -- use #MaxThreadsBuffer.

Unlike #MaxThreads, this setting is not global. Instead, position it before the first hotkey label you wish to have affected by it, which will result in all subsequent hotkeys using that value until another instance of this directive is encountered.

Any hotkey subroutine whose first line is ExitApp, Pause, Edit, Reload, KeyHistory, ListLines, ListVars, or ListHotkeys will always run regardless of this setting.

The setting of #MaxThreads -- if lower than this setting -- takes precedence.

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

Related

#MaxThreads, #MaxThreadsBuffer, Critical, Threads, Hotkey, #MaxHotkeysPerInterval, #HotkeyInterval, ListHotkeys

Example

#MaxThreadsPerHotkey 3