Browse the docs

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 #

ParameterTypeRequiredValuesWhat it does
bundleIdtextYesThe app's bundle identifier.
eventone ofYeslaunch quit activate deactivate whileRunning whileActivelaunch, quit, activate, deactivate, whileRunning or whileActive.
everynumberWith 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 #

When Safari comes to the front
When
  1. Safari comes to the front
Do
  1. Show “Safari is in front”
Open in Switchboard to try it

Gotchas #

  • Apps that are already running when Switchboard starts do not produce a launch event. (whileRunning does fire for them.)

  • Switching between windows of the same app does not fire activate.

  • Not fired reasons: disabled, groupOff, scope, paused, conditionFalse.

See also #

Window title change, Triggers