J23
J23

Reputation: 3211

AutoHotKey: Remap Alt, Ctrl, and Alt+Ctrl

I'd like to use AutoHotKey to remap:

RAlt::Volume_Down
RCtrl::Volume_Up
RAlt & RCtrl::SendInput {Volume_Mute}

While Vol up works fine with the script as above, vol down is non-repeating & mute only works if the buttons are pressed as Alt,Ctrl (not Ctrl,Alt). I understand why, I just haven't been able to come up with a solution. I can map either volume up/down or mute - but if I try to do both, the behavior is always finicky. I think what I need is something to the effect of:

if GetKeyState("RAlt") and GetKeyState("RCtrl")
{
    SendInput {Volume_Mute}
}
else if GetKeyState("RAlt")
{
    SendInput {Volume_Down}
}
else if GetKeyState("RCtrl")
{
    SendInput {Volume_Up}
}

But this just runs & terminates. Is there a way to achieve what I'm after?

Upvotes: 0

Views: 412

Answers (1)

Francisco
Francisco

Reputation: 111

The problem with your solution is that RAlt & RCtrl::SendInput {Volume_Mute} turns RAlt into a "prefix key" and according to the Hotkeys section of Autohotkey help "The prefix key loses its native function".

Try this instead:

RAlt::Volume_Down
RCtrl::Volume_Up

#if GetKeyState("RAlt", "P")
RCtrl::Volume_Mute

#if GetKeyState("RCtrl", "P")
RAlt::Volume_Mute

Upvotes: 2

Related Questions