Home > Back-end >  Hotkey wont work if its modifier is also being used as part of the trigger
Hotkey wont work if its modifier is also being used as part of the trigger

Time:05-05

This issue seems to only occur in this one program.

I have the hotkey Shift a set in this programs hotkey editor dialog, I want to trigger it in AHK using Rshift and w;

RShift & w::
SendInput,  {a}
Return

For the life of me, it will not work. I press Rshift and w and nothing happens at all. Triggering the hotkey manually by pressing shift and a works just fine. The strange thing is the following works:

LCtrl & w::
SendInput,  {a}
Return

So does this:

w::
SendInput,  {a}
Return

I also tried to send Rshift back up before triggering the hotkey, no luck:

RShift & w::
SendInput, {RShift up}
SendInput,  {a}
Return

Is there a rule that says you cant use the same modifier as the target hotkey in the trigger that I missed? please dont suggest that I use other modifier keys, shift [key] is all that I have left.

Any help would be greatly appreciated!

CodePudding user response:

Firstly, you shouldn't use a custom hotkey combination when a modifier exists (unless you have a good reason to):

For standard modifier keys, normal hotkeys typically work as well or better than "custom" combinations. For example, < s:: is recommended over LShift & s::.

And secondly you shouldn't escape keys in a Send(docs) command that don't need escaping:

Enclosing a plain ASCII letter (a-z or A-Z) in braces forces it to be sent as the corresponding virtual keycode, even if the character does not exist on the current keyboard layout. In other words, Send a produces the letter "a" while Send {a} may or may not produce "a", depending on the keyboard layout. For details, see the remarks below.


And then about the problem itself:
I of course can't know if this will work, but I'd simply try the following:

> w::a

This would work because because the remapping syntax actually uses the blind sendmode.
Alternatively, you could, of course, just manually use the blind sendmode:

> w::SendInput, {Blind}a
  • Related