Application event
Runs the macro when an app launches, quits, comes to the front or goes to the background.
app launches, quits or comes to the front
Keyboard Maestro: Application
Details #
Fires on the matching app event, identified by bundle id (for example com.apple.finder). The bundle id comparison is not case sensitive. event is one of launch, quit, activate (the app comes to the front), deactivate (it stops being in front), whileRunning and whileActive. Use * as the bundle id to match every app (launch, quit, activate and deactivate only).
While events. whileRunning and whileActive check once a second. They fire when the app starts running (or comes to the front), including right away if it already is when Switchboard loads, and then every every seconds while that lasts, if you set every. They do not stop the macro when the app quits or goes to the back.
{{triggerValue}} is empty for this trigger. The app's bundle id and name are recorded with the run's Trace as the trigger event, but they are not in the token. Use the {{frontApp}} token when the app is in front, or write one macro per app.
Scope. The Group scope is checked against the app that is in front when the event arrives. For launch and quit that is often a different app from the one named in the trigger.
Secure input does not affect this trigger.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
bundleId | text | Yes | The app's bundle identifier. | |
event | one of | Yes | launch quit activate deactivate whileRunning whileActive | launch, quit, activate, deactivate, whileRunning or whileActive. |
every | number | With whileRunning or whileActive, run again every this many seconds while the state lasts. Runs once on entering it when left out. |
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 #
- Safari comes to the front
- Show “Safari is in front”
Gotchas #
Apps that are already running when Switchboard starts do not produce a
launchevent. (whileRunningdoes fire for them.)Switching between windows of the same app does not fire
activate.Not fired reasons:
disabled,groupOff,scope,paused,conditionFalse.