autohotkey

How do you remap alt+tab?


How do you make your alt+tab functionality work like OSX where it uses meta+tab and not alt+tab, while also respecting the shift key?


Solution

  • There is a special keyword to replicate Alt + Tab functionality.

    I also realized that AutoHotkey will block keyboard signals until you've completed the shortcut by releasing all keys, so any additional tabs that are sent while I held down the control key are ignored.

    Yes, it does that. Hotkeys create something they call "threads" and by default there can be only one. So if you want to trigger the same hotkey again before the previous "thread" has finished, you can use #MaxThreadsPerHotkey directive.

    The code below swaps Alt + Tab and Ctrl + Tab functionality — that is Ctrl + Tab will switch between apps and Alt + Tab between tabs in a browser. The thread limit is 255 which means that you can hold Ctrl and (in theory) press Tab 255 times before it stops working.

    #UseHook
    SendMode Input
    #MaxThreads 255
    
    #MaxThreadsPerHotkey 255
    <!Tab::
    Send {LCtrl down}{Tab}
    Keywait LAlt
    Send {LCtrl up}
    return
    #MaxThreadsPerHotkey
    
    <^Tab::AltTab
    

    I think I've spent more time trying to make AHK hotkeys do what I want than they could possibly save me even if I lived to a hundred.