…s get ignored.
To avoid infinite loops and other side effects, AHK ignores self-generated input events.
It does this by setting a sentinel value in the ExtraInfo field when sending input. In
previous versions, a single sentinel value was used for all scripts, making it impossible
for a script to send input that triggers a hotkey in another script.
The #InputGroup directive provides a way to change the sentinel, so that each script only
ignores input from the other scripts in the same input group.
Like the experimental #InputGroup directive, this allows control over which
generated inputs get ignored. However, instead of working at the file level,
this applies at the HotkeyVariant level like the #IfWinXXX directives.
All hotkeys declared after the directive are assigned the specified InputLevel.
Input generated at a given level can only trigger hotkeys that belong to a
lower InputLevel. Input generated at level 0 cannot trigger any other hotkey
since it is the lowest level. It is also the default level, which means the
default behavior is exactly as in previous versions.
- Rename from InputGroup to InputLevel.
- Change the minimum InputLevel to 0.
- Fix the default InputLevel sent by the hook.
- Add a SendLevel command to change the SendLevel independently from the InputLevel
Now using the original KEY_IGNORE value (equivalent to KEY_IGNORE_BY_SENDLEVEL
at SendLevel 0) as the default for all generated input, and manually specifying
KEY_IGNORE_BY_SENDLEVEL where appropriate. This works much better because:
(a) KEY_IGNORE_BY_SENDLEVEL doesn't make sense in the context of the hook
(or anywhere else outside of a running AHK pseudo-thread), and using
it in such a way would compile fine but cause problems at runtime.
(b) It turns out the vast majority of calls that generate input are doing
so for side effects that should always be ignored at SendLevel 0 anyway.
TODO: Fix the hook to properly handle KEY_IGNORE_ALL_EXCEPT_MODIFIER_BY_SENDLEVEL
at SendLevels other than 0.
SendLevels other than 0. The fix ended up being to not support this mode in
the first place. Based on the use cases this is designed for, any time we're
sending input to be ignored at a given level, it will also make sense to update
the state of the modifiers (i.e., exactly what KEY_IGNORE_ALL_EXCEPT_MODIFIER
As an added bonus, limiting the scope like this allowed for simplification of
some of the supporting code.
This feature should now be functionally complete, with no known major issues.
set to the same as their #InputLevel, and other threads get the level
of the last #InputLevel directive. The SendLevel action provides a way
to set a different value during thread execution. This should rarely
be needed for hotkey threads, and can result in infinite hotkey loops
if not used carefully.