AutoHotkey: Launch or Switch App

By Xah Lee. Date: . Last updated: .

Set Key to Launch App or Switch Window

set a key that launches a browser, but if it is already running, just switch to it.

; launch or switch to Firefox
; http://xahlee.info/mswin/autohotkey_switch_launch_app.html
; Version 2021-02-21 2022-01-19
launchOrSwitchFirefox()
{
if WinExist("ahk_class MozillaWindowClass")
{
WinActivateBottom, ahk_class MozillaWindowClass
}
Else
{
 Run "C:\Program Files\Mozilla Firefox\firefox.exe"
}
Return
}

$F8::launchOrSwitchFirefox()

Use Taskbar Key

Pin the apps you want to the taskbar. Microsoft Windows Taskbar

; make F1 send Win+1
$F1::Send #1

; make F2 send Win+2
$F2::Send #2

AutoHotkey, Switch Window