Search code examples
keyboardautohotkey

Use default modifier keys with AutoHotKey Send


I'm using Autohotkey to map a key combo to a single key. For example, I want to map Win + Mouse back button to Enter using the script:

#XButton1::SendInput "{Enter}"

However, I also want to be able to use additional modifier keys such that combos like Win + Ctrl + Mouse back button activates Ctrl+Enter, without explicitly specifying every single combination of Ctrl, Shift, Alt, and Win

Basically, I want the same effect without so much redundancy as below

#XButton1::SendInput "{Enter}"
#^XButton1::SendInput "^{Enter}"
#+XButton1::SendInput "+{Enter}"
#!XButton1::SendInput "!{Enter}"
#^+XButton1::SendInput "^+{Enter}"
#^!XButton1::SendInput "^!{Enter}"
#+!XButton1::SendInput "+!{Enter}"
#^+!XButton1::SendInput "^+!{Enter}"

Solution

  • I ended up using

    *#XButton1::SendInput "{Blind}{LWin up}{Enter}{LWin down}"
    

    Turns out *#XButton1 will interpret Win + Ctrl + Mouse back button as Win+Ctrl+Enter, which is why it didn't work. This modification simulates a release of the Win button before pressing Enter