SendLevel

AutoHotkey

SendLevel [v1.1.06+]

Controls which artificial keyboard and mouse events are ignored by hotkeys and hotstrings.

SendLevel, Level

Parameters

Level

An integer between 0 and 100, which can be an expression.

General Remarks

By default, hook hotkeys and hotstrings ignore keyboard and mouse events generated by any AutoHotkey script. In some cases it can be useful to override this behaviour; for instance, to allow a remapped key to be used to trigger other hotkeys. SendLevel and #InputLevel provide the means to achieve this.

SendLevel sets the level for events generated by the current script thread, while #InputLevel sets the level for any hotkeys or hotstrings beneath it. For any event generated by a script to trigger a hook hotkey or hotstring, the send level of the event must be higher than the input level of the hotkey or hotstring.

Compatibility:

  • SendPlay is not affected by SendLevel.
  • SendInput is affected by SendLevel, but the script's own hook hotkeys cannot be activated while a SendInput is in progress, since it temporarily deactivates the hook. However, when Send or SendInput reverts to SendEvent, it is able to activate the script's own hotkeys.
  • Hotkeys using the "reg" method are incapable of distinguishing physical and artificial input, so are not affected by SendLevel. However, hotkeys above level 0 always use the keyboard or mouse hook.
  • Auto-replace hotstrings always generate keystrokes at level 0, since it is usually undesirable for the replacement text to trigger another hotstring or hotkey. To work around this, use a non-auto-replace hotstring and the SendEvent command.
  • Characters sent by the ASC (Alt+nnnnn) method cannot trigger a hotstring, even if SendLevel is used.
  • Characters sent by SendEvent with the {Text} mode, {U+nnnn} or Unicode fallback method can trigger hotstrings.

[v1.1.23+]: The built-in variable A_SendLevel contains the current setting.

Every newly launched hotkey or hotstring thread starts off with a send level equal to the input level of the hotkey or hotstring. Every other newly launched thread (such as a custom menu item or timed subroutine) starts off fresh with the default setting, which is typically 0 but may be changed by using this command in the auto-execute section.

If SendLevel is used in the auto-execute section, it also affects keyboard and mouse remapping.

AutoHotkey versions older than [v1.1.06] behave as though #InputLevel 0 and SendLevel 0 are in effect.

Related

#InputLevel, Send, Click, MouseClick, MouseClickDrag

Examples

SendLevel 1
Send btw{Space} ; Produces "by the way ".

; This may be defined in a separate script:
::btw::by the way