DEV Community

Cover image for Switching apps slows down my productivity (and how I fixed it)
Rico Sta. Cruz
Rico Sta. Cruz

Posted on • Updated on


Switching apps slows down my productivity (and how I fixed it)

Switching apps is something I do hundreds of times a day on both MacOS and Windows. I found a way to make this faster, which has made my workflow a lot more efficient.

Image: alt-tab-tab-tab-tab...

☝ Has this been as frustrating for me as anyone else?

Section 1

Is switching apps really difficult?

Well, just a bit. Not much, but small frustrations easily add up over time. Switching with a keyboard always required too much effort for me. I often try one of these, but each one requires some thinking (or typing):

  • win-4 to launch the 4th taskbar app (Windows)
  • ctrl-alt-4 using uBar to emulate Windows behaviour (MacOS)
  • alt-tab-tab-tab to switch to a window (Windows and MacOS)
  • cmd-space firefox to use Spotlight (MacOS)

Section 2

My solution: fixed key bindings

I settled a way that’s easier for me: shortcuts that always do one—and only one—thing. For example, ctrl-win-w will always focus my web browser, where alt-tab requires some thinking to figure out how many Tabs to press.

The result: I save a second of thinking for every app switch I do. For something I do hundreds of times a day, it all adds up! 🎉

Image: ctrl-win-W for Web, ctrl-win-V for Visual Studio Code, and more

☝ Just a small selection of the shortcuts I use.

Section 3

MacOS via Raycast

There are many ways this can be achieved in MacOS. The simplest one I think is with Raycast.

Raycast shortcuts screen

☝ Raycast allows defining shortcuts for many actions, including launching apps.

Section 4

MacOS via Hammerspoon

For my MacBook, I used Hammerspoon, a hotkey automation suite for MacOS. Writing a Lua script to launch apps with hotkeys isn’t too difficult:

-- ~/.hammerspoon/init.lua
hs.hotkey.bind({"ctrl", "cmd"}, "v", "Visual Studio Code", function()
  hs.application.launchOrFocus("Visual Studio Code")

hs.hotkey.bind({"ctrl", "cmd"}, "w", "Firefox", function()

hs.hotkey.bind({"ctrl", "cmd"}, "s", "Slack", function()
Enter fullscreen mode Exit fullscreen mode
☝A simple Hammerspoon script to launch apps from hotkeys. (Docs: launchOrFocus, bind)

Section 5

Windows via AutoHotkey

For my Windows laptop, I used a powerful automation scripting language called AutoHotkey. Here’s an example that launches apps based on start menu items (w and o), URL (c) and file path (v).

UserStartMenu := A_AppData . "\Microsoft\Windows\Start Menu\"
SysStartMenu := "C:\ProgramData\Microsoft\Windows\Start Menu\Programs"

; [w] Firefox (web)
^#w::LaunchOrFocus({ run: SysStartMenu . "Firefox", select: "ahk_exe firefox.exe" })

; [o] Obsidian
^#o::LaunchOrFocus({ run: UserStartMenu . "Programs\Obsidian", select: "ahk_exe Obsidian.exe" })

; [c] Calendar
^#c::LaunchOrFocus({ run: "outlookcal:" })

; [t] Terminal
^#v::LaunchOrFocus({ run: "wt.exe", select: "ahk_exe WindowsTerminal.exe" })

LaunchOrFocus(app) {
  selector := app["select"]
  If (selector and WinExist(selector))
    Run % app["run"]
Enter fullscreen mode Exit fullscreen mode
☝A simple AutoHotkey script to launch apps from hotkeys using WinActivate and Run. Save it as example.ahk and double-click on it to open in AutoHotkey.

Section 6

My shortcuts

I set up shortcuts for the apps I use 90% of the time. For anything not here, I would use Spotlight or Windows Search.

Image: Shortcuts diagram

☝I use the Colemak mod-DH layout, but this can work on any keyboard layout. (The * keys are reserved for moving windows to the side of my screen, but that’s for another article!)

Section 7

Thanks for reading!

Thanks for checking out my post! I'm a web developer who loves open source and supercharging productivity. If you liked this post, consider following me on (@rstacruz) or Twitter (@rstacruz)!

Top comments (0)