AutoHotkey: swapping modifier keys when a specific ahk_exe/process is active, regardless of ahk_class or window title

0

I am trying to make the windows and alt keys swap when I am using REAPER so that my shortcuts on the PC are typed the same (as in the same keyboard locations by muscle memory) as when I am using it on the Mac.

In other words, on a Windows/PC keyboard, the alt key is in the location where the command key is on the Mac keyboard, and the windows key is in the location of the option key. Since the corresponding/cross-platform mapping for these keys is actually alt=option and command=windows, I just need to remap each of these modifier keys to the other so that, when used alone or in combination with any other keys or modifiers, and only when I'm using REAPER, pressing the alt key will always send a windows keypress, and pressing the windows key will always send alt.

I have tried the following, but it doesn't seem to work:

#IfWinActive ahk_class reaper
!::#
#::!

I've also tried this:

#IfWinActive ahk_exe reaper.exe
!::#
#::!

But that doesn't work either.

The main problem is that there can be any number of different windows open/active in REAPER, and most of them have a different title and class. So I really need this modifier keyswap to be dependent on the active process and not the active window. The ahk_exe that is shown in Window Spy when REAPER is the active process is reaper.exe.

Someone PLEASE help me out here. I'm losing my mind from going between work and home and constantly forgetting shortcuts, or hitting the wrong ones and doing things I don't want to be doing.

Thanks!

MikMak

Posted 2019-01-17T11:58:43.147

Reputation: 1 372

Answers

1

  • "!" and "#" are the modifier symbols for the Alt- and the windows-key.

  • Modifier symbols are used only in key-combinations in order to modify other keys.

  • Unlike Control/Alt/Shift, there is no generic/neutral "Win" key because the OS does not support it. (See Modifier_keys)

In this case you have to use the full name of those keys, otherwise AHK remaps the literal keys/characters ! to # and # to !:

#IfWinActive ahk_exe reaper.exe

    Alt::LWin
    LWin::Alt
    RWin::Alt

#IfWinActive

user3419297

Posted 2019-01-17T11:58:43.147

Reputation: 2 055