# Hammerspoon Mac 版：用 Lua 脚本自动化 macOS

_As of 2026-11-27_

- **Version:** 1.1.1
- **macOS min:** 13
- **License:** Free

Hammerspoon 是一款免费开源的 macOS 自动化工具。它把窗口、快捷键、Wi-Fi、音频设备等系统功能开放给 Lua 脚本，让你自己编写快捷键和对各种事件的响应。

Hammerspoon is a bridge between macOS and a scripting language. On its own it does nothing; a few lines of Lua let it move windows with a hotkey, react when your Mac joins a Wi-Fi network or warn you when the battery runs low.
What it does well

Hotkeys. Bind any key combination to a function that moves and resizes windows, launches apps or runs AppleScript.
Events. Scripts can react to a Wi-Fi network change, a USB device being plugged in, the battery level or a changed file.
Spoons. Ready-made plugins that you download, open to install, and load with a line of configuration.
Console and reload. A built-in console runs Lua interactively, and the configuration reloads without restarting the app.

Who it is for
People comfortable with a little code who want automation that ready-made tools do not offer.
Good to know
The Lua version offered here is no longer maintained; its maintainer now works on Hammerspoon 2, a separate app scripted in JavaScript that is still in beta. If you prefer clicking to coding, BetterTouchTool covers hotkeys, gestures and window actions in a settings window.
How to install

Unzip the download if your browser has not done it already.
Drag Hammerspoon to Applications.
The first time you open it, macOS asks you to confirm an app downloaded from the internet; click Open.
Grant access in System Settings → Privacy &amp; Security → Accessibility, then write your first script in ~/.hammerspoon/init.lua.

> Source: https://macsoftpark.net/zh/hammerspoon/
