Search code examples
scriptingkeyboardkeyboard-shortcutsautohotkeyhotkeys

How to resolve a hotkey conflict?


I bound Alt+Space to an action, for example:

!Space::Send, Foo

Now how to trigger the original Alt+Space's action (as shown in the image below) through code?

enter image description here


Solution

  • To distinguish between user keystrokes and "artificial" ones you have to make use of keyboard hooks.

    These hooks are typically setup automatically. (Although there's the possibility of manual changes with #InstallKeybdHook)

    But even if available they are not always in use. To force them you can use #UseHook or the modifier symbol "$" in front of hotkey definitions.

    An example related to your question:

    $!Space:: MsgBox, Action configured with hook.
    F2:: Send, !{Space} ; This can still trigger the old behavior.
    

    A different approach would be temporarily to turn off your hotkey through the Hotkey command.