Browse the docs

Type text

Puts text into the front app: inserted through accessibility when the app allows it, else pasted or typed.

Type text into the front app

Keyboard Maestro: InsertText ByTyping, InsertText ByPasting

Details #

Types the text as if you were at the keyboard, into whatever has focus. The text can use variables and expressions.

There are three ways to get text in:

  • insert sets the selected text of the field that has focus, through accessibility. The text replaces the selection as if you had typed it, your clipboard is not touched, no key press is involved, and one ⌘Z in the app takes it back. Switchboard reads the field back to check the text really arrived; an app that says yes and does nothing counts as not accepting it.

  • paste puts the text on the clipboard, presses ⌘V, waits 0.3 seconds, and puts your old clipboard back. Fast for long text. If you copy something else in that moment, your new copy is left alone.

  • keys sends the characters as key events, in pieces of at most 20 characters. Newlines become the Return key and tabs become the Tab key. Works almost everywhere, including apps that do not accept paste.

auto is the default. It tries insert first. If the focused thing is not a text field the app lets Switchboard edit, or the read-back shows nothing changed, it does what auto always did: types text of 200 characters or fewer by keys, and pastes anything longer or with fill-in fields. The step's trace says which one landed the text and why insert was skipped: "insert: the app said yes but the text did not change; typed 12 characters by keys". Choosing insert by hand behaves the same way. paste and keys are always exactly what they say.

Settings › Typing lists apps that should always paste or always type keys, for an app where automatic does the wrong thing.

The output holds the method used and the number of characters. An empty text does nothing and says so.

Parameters #

ParameterTypeRequiredValuesWhat it does
texttextYesThe text to type. Required.
delayMsnumberMilliseconds to wait between pieces when typing by keys. Raise it for apps that drop characters. Ignored when pasting.
methodone ofauto insert keys pasteauto, insert, paste or keys. Any other value fails.
replaceSelectionyes / notrue (the default) replaces whatever is selected. false puts the caret after the selection first, so the text is added instead of replacing it. Only used when the text is inserted through accessibility.

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

Examples #

Type a greeting into the front app (really types)
Do
  1. Type “Hello,⏎Thanks for your note.”
Open in Switchboard to try it

Insert at the caret without replacing a selection (really inserts):

Add a signature after the selection (really inserts)
Do
  1. Type “-- Alex”
Open in Switchboard to try it

Paste a long block, whatever its length:

Paste a snippet (really pastes)
Do
  1. Type “Best regards,⏎Alex”
Open in Switchboard to try it

Gotchas #

  • Typing goes to the front app. If another window grabs focus partway through, the rest of the text goes there. Use Activate app and Wait first.

  • Insert never goes into a password field: the step fails and says so. While secure input is on because of another app, insert still works; paste and keys do not.

  • If an app takes the text but leaves the caret somewhere odd, Switchboard puts the caret back after the text. If the field changes in a way that is not the text, the step fails rather than trying paste and doubling it.

  • The paste method briefly replaces your clipboard. A clipboard history app may record the text.

  • Characters are typed as Unicode, so accents and emoji work. Shortcuts that depend on key codes are not triggered by typed text; use Press keys for those.

See also #

Press keys, Clipboard, Set field value