Browse the docs

Read a value from an app

Reads one number or word an app shows right now (the red number on its Dock icon, a menu bar item, a window title, a script's answer, a file) and hands it to the next steps.

Read from of app

Details #

Reads once, with no kit. The value is the step's output, and into stores it in a variable. app is the app's name (Mail) or bundle id (com.apple.mail) and from says where to read:

fromReads
dockBadge (default)the red number on the app's Dock icon, through the Dock's accessibility tree. Works for nearly every app that counts something, hidden or not.
menuBarExtrathe title of the app's menu bar item (item picks one by words in its title)
windowTitlethe app's main window title
appleScript, jxaa script's result (script)
intentan App Intent that returns a value (intent, params)
filea file's text, or with sql the first column of a read-only query on a SQLite file (path)
ocrtext on screen (area), the last resort: it needs Screen Recording

as turns the text into a value: number (1.2k, 1,234 and 3 unread all read as numbers), date, boolean, list, or text (default). regex takes the first group of a pattern from the text first ((\d+) errors?). When there is nothing to read, or the text isn't one of those, the value is default.

The output is {value, at, stale}.

The same keys, in a kit's readings, make a value that stays current: a token, a condition and a trigger.

Parameters #

ParameterTypeRequiredValuesWhat it does
apptextThe app: its name or bundle id.
arearecord
asone ofnumber text date boolean list, default, regex: What to make of the text.
defaultany value
everyany value
fromone ofdockBadge menuBarExtra windowTitle anchor appleScript jxa intent file notification ocrWhere to read it. Default: dockBadge.
intenttext
intotextThe variable that receives the value.
itemtext, script, intent, params, path, sql, area: What the source needs.
keytext
nametext
paramsrecord
pathtext
regextext
sampleany value
scripttext
separatortext
sourceone ofscreen window
sqltext

Every step also accepts label, onFailure, timeout and dryRunSafe.

Examples #

Say how many unread messages Mail has
Do
  1. Read the Dock badge of “Mail”
  2. Show “Mail has {{unread}} unread”
Open in Switchboard to try it

Gotchas #

  • The Dock needs Accessibility, which Switchboard's engine already has for its other steps.

  • An app in a Dock folder has no tile of its own, so no badge.

  • anchor and notification readings belong to a kit: an anchor is a kit's, and a notification is gone after it is posted.

  • Scripts take up to 20 seconds; the step fails after that.

  • A dash before a number reads as a minus, as it does everywhere: a title like “Inbox – 3 unread” reads as -3. Use regex ((\d+) unread) to take the number out of a title.

See also #