vexe
vexe

Reputation: 5615

AHK recursive map? (Map RAlt to RWin which is mapped to other keys)

I have a bunch of RWin+X => Y mappings. I would like RAlt to be mapped to RWin so that RWin+X == RAlt+X. For example:

; RWin+J => Left
>#j::SendInput,{LEFT}

Which works fine, I can hold down RWin and press j and it would keep sending Left. Now let's add before that map the following:

RAlt::RWin

If I hold RAlt then press j, it would send a Left correctly, but if I keep holding RAlt and press j again, it would send a j and not Left. I would have to release RAlt and press it again.

Is there any way to fix that?

Upvotes: 1

Views: 328

Answers (1)

errorseven
errorseven

Reputation: 2682

This what I came up with based on your issue. It's a work around solution:

#J::
If (GetKeyState("RAlt", "P") Or GetKeyState("RWin", "P")) {
    SendInput,{LEFT}
}
Return

RAlt::
While GetKeyState("RAlt", "P") {
        ; Add any Key in {Key} format followed by Period . that you want to act as an EndKey.
        Input, Key, L1 M T1, {space}.{esc}.{shift}.{enter}
                         .{tab}.{backspace}.{alt}.{home}
                         .{delete}.{pgup}.{pgdn}.{end}
                         .{up}.{down}.{left}.{right}
            If (Key <> "") {
                SendInput, {RWin down}{%Key%}{Rwin Up}
                }
            If InStr(ErrorLevel, "EndKey:") 
                Send % "{" . StrReplace(ErrorLevel, "EndKey:") . "}"
    }
Return

Upvotes: 1

Related Questions