DEV Community

Sergio Farfan Cardenete
Sergio Farfan Cardenete

Posted on

I Built a Windows-Style Alt+Tab Window Switcher for macOS in Pure Swift

One of my biggest frustrations after spending years on Windows was losing a proper window switcher when I moved to macOS. Cmd-Tab switches between applications, not windows. If you have four Terminal windows open, you cannot directly jump to a specific one — you have to Cmd-Tab to Terminal, then use Cmd-` to cycle through its windows. It is a two-step dance every single time.

So I built AltTab — a lightweight, zero-dependency macOS utility that brings back the Windows Alt-Tab experience using Option-Tab.


What It Does

Hold Option and tap Tab — a panel appears showing thumbnails of every open window across all your apps. Cycle through them with Tab / Shift-Tab or the arrow keys, then release Option to jump straight to the selected window. Click any thumbnail to switch instantly.

Shortcut Action
Option-Tab Open switcher / next window
Tab Cycle forward
Shift-Tab Cycle backward
← / → Navigate left / right
Escape Cancel
Enter Confirm and switch
Click Select and switch immediately

Minimized windows are included and will automatically unminimize when selected. No Dock icon, no clutter — just a clean menu bar icon.

AltTab menu bar menu showing Launch at Login, About AltTab, and Quit AltTab options


Installation

Requirements: macOS 13 Ventura or later · Full Xcode installation

One-liner install

git clone https://github.com/sergio-farfan/alttab-macos.git && cd alttab-macos && ./build.sh install && open ~/Applications/AltTab.app
Enter fullscreen mode Exit fullscreen mode

Then open System Settings → Privacy & Security → Accessibility and grant permission to AltTab. That is all — press Option-Tab and it just works.

Build options

./build.sh build          # Build Release binary only
./build.sh install        # Build and install to ~/Applications
./build.sh install --system  # Build and install to /Applications (requires sudo)
./build.sh run            # Build and launch immediately
./build.sh uninstall      # Remove the installed app
Enter fullscreen mode Exit fullscreen mode

Permissions

  • Accessibility (required) — needed to intercept the Option-Tab hotkey and raise windows
  • Screen Recording (optional) — enables live window thumbnails; gracefully falls back to app icons if denied

How It Works

Global hotkey interception — A CGEvent tap installed at the session level intercepts Option-Tab system-wide before it reaches any app, without stealing keyboard focus.

Complete window discovery — On-screen windows come from CGWindowList. Minimized windows require a separate AXUIElement query per app — no single API covers both. Results are deduplicated and merged.

MRU ordering — Windows are sorted most-recently-used first. App-level focus is tracked via NSWorkspace notifications; intra-app window switches (like Cmd-`) are caught by per-app AXObserver callbacks.

Non-activating overlay — The switcher is an NSPanel with .nonactivatingPanel, so it appears on screen without stealing focus. Releasing Option activates the target window, not AltTab.

Live thumbnails — macOS 14+ uses ScreenCaptureKit for async, high-quality captures. macOS 13 falls back to CGWindowListCreateImage. If Screen Recording permission is denied, app icons are shown instead — no crash, no prompt.


Project Stats

  • ~2,000 lines of Swift across 9 source files
  • Zero external dependencies — pure Swift + AppKit
  • MIT licensed — fork it, modify it, ship it
  • macOS 13+ (Ventura, Sonoma, Sequoia)

Try It Out

The code is on GitHub: github.com/sergio-farfan/alttab-macos

If you have been frustrated by macOS window switching, give it a try. And if you are curious about the low-level macOS APIs — CGEvent taps, AXUIElement, ScreenCaptureKit — the codebase is small enough to read in an afternoon.

Feedback, issues, and PRs are welcome!

Top comments (0)