Reputation: 21326
I'm having trouble figuring out how to disable key remappings in AutoHotkey v2. Just to provide a simple test for reproducing the problem, here I map F11
to Home
(which works), and then I try to disable it:
F11::Home
Hotkey "F11", "Off"
AutoHotkey tells me:
Error: Nonexistent hotkey.
Specifically: F11
(The error message points to the Hotkey "F11", "Off"
line.)
I'm just following the remap documentation for v2, which clearly says:
When a script is launched, each remapping is translated into a pair of hotkeys. For example, a script containing
a::b
actually contains the following two hotkeys instead:*a:: { SetKeyDelay -1 Send "{Blind}{b DownR}" } *a up:: { SetKeyDelay -1 Send "{Blind}{b Up}" }
It then goes on to say:
Since remappings are translated into hotkeys as described above, the Suspend function affects them. Similarly, the Hotkey function can disable or modify a remapping. For example, the following two functions would disable the remapping
a::b
.Hotkey "*a", "Off" Hotkey "*a up", "Off"
That seems exactly what I'm doing here. Is this an AutoHotkey v2 bug?
On a related note, once I get this working, do I need to disable/enable the implicit "up" hotkey as well when I toggle a short-form hotkey assignment, like this?
Hotkey "F11", "Off"
Hotkey "F11 up", "Off"
…
Hotkey "F11", "On"
Hotkey "F11 up", "On"
Or do I simply need to toggle the key itself and the "up" key will get toggled automatically?
Upvotes: 1
Views: 800
Reputation: 21326
Ah, it appears the mistake was mine, missing the tiny detail in the documentation that a *
is added to the hotkey names, which represents a wildcard. Thus my code should be:
F11::Home
Hotkey "*F11", "Off"
That seems to work. I'm still in doubt about whether I need to toggle just "*F11"
or both "*F11"
and "*F11 up"
, though.
Upvotes: 1