Before a key, click or quit
Catches a key press, a click on a button you recorded, or Quit in one app before the app sees it, runs a quick check macro, then lets it through, blocks it with a reason, or asks "Send anyway?".
Before a key or click in app
Details #
Every other trigger starts a macro after something happens. This one starts it before: the key, click or Quit is held back for a moment, the macro checks what it needs to, and the macro's answer decides what the app gets.
The answer is the macro's returned value, and the three steps Let it through, Block it and Ask Send anyway? return it for you:
| The macro ends with | What happens |
|---|---|
hook.allow, or ends without returning anything | The key, click or Quit goes through as if nothing was in the way. |
hook.block | It is dropped, and the reason shows for two seconds. |
hook.ask | A small panel opens at the pointer with your question and two buttons. Return and Esc pick the cancel button; Command-Return picks the other. |
Keys typed while the check runs are held and go to the app afterwards, in the order you typed them. Nothing is lost, and a check that finishes in a few milliseconds is not noticeable.
The macro gets these inputs:
| Input | What it holds |
|---|---|
app | The bundle identifier of the app. |
on | keys, click or quit. |
keys | The key combination, for keys and quit. |
element | For click: {role, title, value} of what was clicked. |
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
app | text | Yes | Required. The bundle identifier of the app to guard, such as com.apple.mail, or * for every app (keys and Quit only). A guardrail only ever looks at its own app. | |
deadline | number | How many seconds the check may take. Default 2, at most 10. | ||
keys | text | For keys: the combination, such as cmd+return. quit always means Command-Q. | ||
locator | locator | For click: the button, recorded with the Recorder like any other element. | ||
on | one of | keys click quit | keys (the default), click or quit. | |
onTimeout | one of | allow block | What happens when the check is too slow or fails: allow (the default) or block. |
Every trigger also takes Limits: a cooldown, the first time each day, every nth time, twice within seconds, a chance, only while you are at the Mac, on one Mac, or in a State. See Limits on any trigger.
Examples #
- Before ⌘↩ reaches Mail
- Read the mail being written
- If body matches “(?i)attach(ed|ment)” and {{ attachmentCount }} is 0
- Ask “No attachment. The message mentions one.” with “Send Anyway”
Gotchas #
If the check is slow or fails, the action goes through (or is blocked, if you set
onTimeouttoblock). The run's trace says which.Secure input turns guardrails off, such as while a password field has focus. The menu bar item says so.
Only the key equivalent is guarded. Choosing the same command from a menu, the Dock's Quit, Force Quit and logging out can't be caught.
A hot key macro that claims the same key runs instead, and the guardrail never sees it.
If you switch to another app while a check runs, the held action is dropped rather than sent to the wrong app.
A click is looked at only in an app that has a click guardrail, and Accessibility has 80 milliseconds to answer. An app that does not answer is not guarded for that click.
Settings > Guardrails shows each guardrail's delay. A slow one is marked with an amber dot.
See also #
Let it through (guardrail), Block it (guardrail), Ask Send anyway? (guardrail), Read the mail being written, Hotkey, Guardrails: check before it happens