KeyRoutines

Hammerspoon for Windows: the same watchers, without Lua

Hammerspoon only runs on macOS, and there's no Windows port. On Windows, KeyRoutines covers the things most people put in their Hammerspoon config: hotkeys, window placement, and watchers for apps, Wi-Fi, USB devices, folders, sleep and wake. The big difference is that you build routines from blocks instead of writing Lua, so you trade some of Hammerspoon's unlimited flexibility for not having to maintain code.

Hammerspoon → KeyRoutines

In HammerspoonIn KeyRoutines
init.lua configRoutines built in a visual editor; each one is a trigger and a list of steps, no code.
hs.hotkeyHotkey trigger, including key sequences, hold and double-tap.Hotkey
hs.window, hs.grid and hs.layoutMove and resize, Window state, Apply layout and Remember layout.Move and resizeWindow stateApply layoutRemember layout
hs.application.watcherApp launched, App quit and App focused triggers; App is running condition.App launchedApp quitApp focusedApp is running
hs.wifi.watcher and hs.usb.watcherWi-Fi network joined or left; Device connected and disconnected.Wi-Fi network joined or leftDevice connectedDevice disconnected
hs.pathwatcherFolder changed, with file patterns and a settle time so half-written files are skipped.Folder changedDownload finished
hs.caffeinate and its watcherKeep awake; Going to sleep, Woke up, PC locked and PC unlocked triggers.Keep awakeGoing to sleepWoke upPC lockedPC unlocked
hs.timerEvery … and At a time triggers; Delay inside a routine.Every …At a timeDelay
hs.alert, hs.notify and hs.chooserShow banner, Show notification and Choose from a list.Show bannerShow notificationChoose from a list
hs.audiodeviceSet default audio device, Set volume, Mute or unmute, App volume.Set default audio deviceSet volumeMute or unmuteApp volume
hs.eventtap (sending keys)Press keys and Type text, including to desktop apps that aren't in front.Press keysType text
hs.execute and hs.httpRun command, Run PowerShell and HTTP request (all Pro).Run commandRun PowerShellHTTP request

What's different

  • Hammerspoon is a programmable bridge to macOS: anything you can write in Lua, you can do. KeyRoutines offers a fixed set of blocks, with PowerShell, command and JavaScript steps in Pro as escape hatches. There's no Lua.
  • Hammerspoon is free and open source. KeyRoutines is free with an optional one-time Pro upgrade, and it isn't open source.
  • Hammerspoon has a large set of community Spoons. KeyRoutines has built-in templates but no third-party plugin system in 1.0.
  • Hammerspoon can intercept and rewrite any key event; KeyRoutines has no always-on key remapping in 1.0.
  • Hammerspoon can draw your own on-screen UI; KeyRoutines offers banners, notifications and question dialogs, not custom drawing.

Moving over

  1. 1

    Read your init.lua as a list of jobs

    Each hs.hotkey.bind or watcher is usually one job. Write them down as "when X, do Y" and turn each into its own routine.

  2. 2

    Swap watchers for triggers

    An application watcher becomes App launched or App quit, a Wi-Fi watcher becomes Wi-Fi network joined, a path watcher becomes Folder changed.

  3. 3

    Replace window math with layouts

    Instead of computing frames, arrange your windows once and capture them in Apply layout. Monitors are recognised by the screen itself, not a number that can change.

  4. 4

    Keep the odd script

    If something truly needs code, Pro's Run PowerShell or Run JavaScript step can hold it, with the rest of the routine still in blocks.

Questions

Does Hammerspoon run on Windows?
No. Hammerspoon is built on macOS's own APIs and only runs on a Mac.
Can I use Lua in KeyRoutines?
No. Pro has PowerShell, command and JavaScript steps. Most routines need no code at all.
Is AutoHotkey closer to Hammerspoon?
In spirit, yes: both are scripting tools. If you want to keep writing code, AutoHotkey is the natural Windows choice. If you'd rather click routines together, use KeyRoutines.
Can KeyRoutines snap windows to a grid?
Move and resize puts a window on a chosen monitor and part of the screen, and Apply layout does many windows at once. For dragging windows into zones by hand, Windows Snap or PowerToys FancyZones fit better.

Hammerspoon is an open-source project owned by its contributors; KeyRoutines is not affiliated with or endorsed by the Hammerspoon project.

Coming from somewhere else?

Try KeyRoutines instead of Hammerspoon

Free from the Microsoft Store for Windows 11 and 10. Pro is a one-time upgrade.