Hammerspoon can substitute for Keyboard Maestro for macOS shortcut-driven window and application automation when Lua-based authoring is acceptable. It offers an API and plugin model rather than direct compatibility with Keyboard Maestro macros. Existing action sequences, triggers and permission requirements must be rebuilt and checked for the specific workflow.[2][3][5]
Overview
Hammerspoon is an open-source macOS automation environment that connects a Lua scripting engine to operating-system APIs. It can coordinate windows, applications, input, clipboard data and system events. It does not provide a finished workflow immediately after installation: users supply a Lua configuration or load suitable extensions.[2]
Lua configuration
The main configuration connects triggers to actions, such as a shortcut that rearranges windows or an event handler responding to an application change. The project exposes macOS capabilities through modules rather than one fixed macro format. This favors users comfortable describing behavior in code and consulting an API reference.[2]
Spoons and reusable modules
Prebuilt plugins called Spoons package reusable behavior. The getting-started guide distinguishes installing a Spoon from loading and activating it in the configuration. A downloaded extension therefore is not automatically a complete working setup; its initialization, options and required dependencies remain part of the workflow.[3]
Runtime behavior
The guide explains that Lua objects such as watchers need retained references or they can be garbage-collected. Reloading configuration destroys the current interpreter and creates another one. These details matter for long-running event automation: a script that creates a watcher once is not enough if its lifetime is not maintained.[3]
Window-management scope
The window API documents that its general window-listing function sees the current Mission Control Space, with additional qualifications for visible displays, hidden applications and minimized windows. A separate window-filter module addresses broader tracking needs. Multi-Space automation should use the appropriate API instead of assuming that every function returns every window on the Mac.[4]
Licensing and access
Hammerspoon is MIT-licensed. Its setup guide calls for Accessibility access to enable relevant desktop-control operations. That permission is a deployment requirement for the intended automation, not proof that a script can manipulate every application without restriction. Older macOS systems may also require a compatible earlier release.[1][2][3]
Capabilities & limitations
All-Space window enumeration
limited
The general allWindows API is limited to the current Space; broader tracking uses other APIs.[4]
Desktop automation and text expansion · macOS · Operating-system, application and permission requirements apply