Skip to main content

Firefox on Win+B with AutoHotkey

A great thing about the Windows key is that no application other than Windows creates shortcuts involving this key. So you can bind most combination like Win+B (and Win+T for Thunderbird) to custom actions, provided you have a Free Software tool doing that for you like AutoHotkey. Making it open Firefox the way I want (with focus in the location bar) is tricker than it should be though. This part in my config seems to work well:

#b::
{
    SetTitleMatchMode, 2
    IfWinExist, Firefox, ,Thunderbird,
    {
        WinActivate
        Send {Ctrl down}{l}{Ctrl up}
    }
    else
    {
        Run Firefox
        Loop, 20
        {
            IfWinExist, Firefox, ,Thunderbird,
            {
                WinActivate
                Send {Ctrl down}{l}{Ctrl up}
                return
            }
            Sleep, 100
        }
    }
    return
}

The Thunderbird in there is to workaround an occasional confusion with the Thunderbird window. No idea why it's happening.