#Note/Permanent #Productivity/Automation #Software/Scripts #Workflow/ApplicationSwitching
Rapid application switching automation allows instant access to frequently used applications through consistent keyboard shortcuts, eliminating the need to manually search for or click on applications in taskbars or docks.
## The Problem
Switching between applications typically requires multiple steps: looking for the app in taskbar/dock, clicking it, or using Alt+Tab to cycle through many windows. This creates friction and interrupts workflow, especially when working with the same set of core applications repeatedly.
## Windows Solution: AutoHotkey
[AutoHotkey](https://www.autohotkey.com/) provides powerful window management capabilities on Windows systems. The script below maps Alt+number keys to specific applications:
```autohotkey
#NoEnv
#SingleInstance force
SendMode Input
; Press Alt+1 to switch to/launch browser (Firefox)
!1::
if WinExist("ahk_exe firefox.exe")
WinActivate, ahk_exe firefox.exe
else
Run, "C:\Program Files\Mozilla Firefox\firefox.exe"
return
; Press Alt+2 to switch to/launch VS Code
!2::
if WinExist("ahk_exe Code.exe")
WinActivate, ahk_exe Code.exe
else
Run, "[Path to VS Code]/Code.exe"
return
; Win+` cycles through windows of the same application
; Similar to cmd+` on macOS
#`::
WinGet, currentProcess, ProcessName, A
WinGet, windowList, List, ahk_exe %currentProcess%
if (windowList > 1) {
WinGet, currentID, ID, A
Loop, %windowList% {
if (windowList%A_Index% = currentID) {
nextIndex := (A_Index >= windowList) ? 1 : A_Index + 1
WinActivate, % "ahk_id " . windowList%nextIndex%
break
}
}
}
return
```
## macOS Solution: Hammerspoon
[Hammerspoon](https://www.hammerspoon.org/) offers similar functionality on macOS with a more streamlined configuration approach:
```lua
-- Constants
MODIFIERS = {"alt"}
-- App configuration
APPS = {
{shortcut = "1", name = "Firefox"},
{shortcut = "2", name = "Visual Studio Code"},
{shortcut = "3", name = "VMware Fusion"},
{shortcut = "4", name = "Slack"},
{shortcut = "5", name = "Finder"},
{shortcut = "6", name = "Obsidian"},
{shortcut = "7", name = "Spotify"},
}
-- Bind application shortcuts
for _, app in ipairs(APPS) do
hs.hotkey.bind(MODIFIERS, app.shortcut, function()
hs.application.launchOrFocus(app.name)
end)
end
```
## Key Benefits
**Muscle Memory Development**: Using consistent shortcuts across both platforms (Alt+1 for browser, Alt+2 for editor, etc.) creates reliable muscle memory that works regardless of operating system.
**Launch or Focus Logic**: Both scripts implement smart behavior - if the application is already running, they switch to it; if not, they launch it. This eliminates the mental overhead of remembering whether an app is open.
**Same-App Window Cycling**: The Windows script includes ``Win + ` ``
for cycling through multiple windows of the same application, useful for applications like browsers with multiple windows.
## Implementation Notes
For Windows: Save the AutoHotkey script as a `.ahk` file and ensure AutoHotkey is installed. Update file paths to match your system's application installations.
For macOS: Install Hammerspoon and add the Lua script to your `~/.hammerspoon/init.lua` file. The script uses application names as they appear in the Applications folder.