Browse the docs

Get the current thing

Reads what you are on (selected text, the Finder selection, the browser tab, the Mail message or the element under the pointer) as a typed thing.

Get the current thing from source

Details #

Answers "what am I on?" for a macro that started some other way (a hotkey, a menu item, a schedule). The step looks in order, and the first place that has something wins:

  1. the text selected in the front app (read through Accessibility first, then by copying and putting the clipboard back);

  2. the Finder selection, when Finder is in front: each file is a file thing;

  3. the front browser tab: a url thing with the page title;

  4. the selected Mail message: a mail.message thing with sender, subject and message id;

  5. the Accessibility element under the pointer.

Text goes through the recognizers: the built-in ones and the ones you teach in Library ▸ Thing Types. "Call 555-1234 about ABC-12" is a phone number, and a ticket, and text. The best match is the thing; the others are its alternatives; the whole text is always the last.

The step leaves the thing under into as {value, type, label, source, fields, alternatives}, and sets the run's {{thing}} (the value), {{thing.type}}, {{thing.label}}, {{thing.source}} and {{thing.<field>}}, the same variables a macro that takes a thing starts with.

Parameters #

ParameterTypeRequiredValuesWhat it does
intotextA variable that receives the thing.
requiredyes / noFail the step when there is nothing to act on. Otherwise the step succeeds with an empty result.
sourceone ofauto selection finder browser mail element clipboardauto (default), selection, finder, browser, mail, element or clipboard. A named source reads only that one.

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

Examples #

Open whatever is selected, if it is a link
Do
  1. Get the current thing from selection
  2. If the current thing is a link
  3. Open {{thing}}
Open in Switchboard to try it

Gotchas #

  • Dry run. Reading the selection can copy and restore the clipboard, so a dry run doesn't do it.

  • The copy-and-restore fallback is skipped in secure input (a password field) and in the Finder, and the whole read gives up after about half a second.

  • Clipboard history and the clipboard trigger ignore the transient copy.

See also #