Code: Select all
#Requires AutoHotkey v2.0
ih := InputHook('V')
ih.KeyOpt('{All}', '+S')
ih.KeyOpt('abc{Enter}', '-S')
; ih.KeyOpt('{All}', '-S')
ih.Start
ih.Wait
MsgBox ih.EndReason
Code: Select all
#Requires AutoHotkey v2.0
ih := InputHook('V')
ih.KeyOpt('{All}', '+S')
ih.KeyOpt('abc{Enter}', '-S')
; ih.KeyOpt('{All}', '-S')
ih.Start
ih.Wait
MsgBox ih.EndReason
ih.KeyOpt('{All}', '+S') applies S to vk0D (VK_RETURN), sc01C (Enter) and sc11C (NumpadEnter).Specify the string {All} (case-insensitive) on its own to apply KeyOptions to all VK and all SC
...
When a key is specified by name, the options are set either by VK or by SC. Where two physical keys share the same VK but differ by SC (such as Up and NumpadUp), they are handled by SC.
...
To prevent an option from affecting a key, the option must be removed from both the VK and the SC of that key, or sc000 if the key has no SC.
If "set" can mean to add or remove an option, this may be saying that {Enter} -S is equivalent to {sc01C} -S, which won't affect {vk0D} +S. However, it isn't entirely true that "options are [added/removed] either by VK or by SC" due to the following exception:When a key is specified by name, the options are set either by VK or by SC.
Options that were "set" to false/disabled obviously aren't affected by setting more options to false/disabled, so perhaps this implies "set" means added/enabled. There is a stronger implication of this further down:However, when an option is removed by key name and that name is handled by VK, the option is also removed for the corresponding SC (according to the script's keyboard layout). This allows keys to be excluded by name after applying an option to all keys.
Unicode events are not affected by options which have been removed/disabled.Unicode events, such as those sent by SendEvent "{U+221e}" or SendEvent "{Text}∞", are affected by options which have been set for either vkE7 or sc000. Any option applied to {All} is applied to both vkE7 and sc000, so to exclude Unicode events, remove the option from both.
So it is unclear what my intention was.When removing options by key name, remove from both VK and SC.
Source: Improved InputHook handling of SC vs. VK. · AutoHotkey/AutoHotkey@7bfdb47
[v2.1-alpha.10]: If the name is handled by SC, the option is also removed from the corresponding VK (i.e. regardless of whether the name is handled by VK or SC, the option is removed from both).
Source: InputHook - Syntax & Usage | AutoHotkey v2