Table of Contents

Set Variable to Text Action

The Set Variable to Text action allows you to set a selected variable to plain text, by either typing in the text box, or selecting a Token.

Alternatively (v9.0+), you can Prepend the text to the variable, or Append the text to the variable by selecting from the action (gear) ⚙ menu.

You can (v11.0+) set a specific array entry within the action. You can delete the entry by setting it to %Delete%.

Examples

Set To Text You Type

Set to The Clipboard

Set To Another Variable

See below for how to use dynamic variable names.

Combine Multiple Variables and Text

There is no need to use any operators when combining text with multiple variables or other tokens. Just enter the text and variables/tokens as you would like them to appear in the Variable being set by this Action.

Append to Variable

You can append directly to a variable with the Append variant of the action:

 Append to Variable

or equivalently using text tokens to expand the variable:

 Set Append to Variable

Set Second Line of Variable

You can specify an array entry of the variable to set. By default, entries are comma separated, but you can specify an specific separator after the closing square bracket (]),

 Set Second Line of Variable Example

Setup

Configure the Action as Needed

Unlike most places you specify a variable, the variable name itself is a text token field, so you can set a variable whose name changes.

The Set Variable to Text action allows you to control what text processing happens in the gear menu (7+) :

Most other Text Fields in Keyboard Maestro process both text tokens and (except for regular expression fields) backslash characters.

Tip: leave notes for yourself about what you're doing. Click on the gear icon at top right of the action to select Set Note…. A window appears where you can enter text. Click the OK button to save the text of the note for future reference.

How To Use Dynamic Variable Names

In some languages, this is known as indirection, where one variable is really referring to another variable. This is a bit complicated, and you may not often need it, but it is very useful when you do need it.

Dynamic Determination of Variable Name in Text Area Block

This requires two steps (two Actions):

The Steps Are

Dynamic Determination in Variable Name Block

Since the Variable Name block of the Set Variable to Text Action accepts tokens, we can just use it directly if we just need to concatenate two more more Variables, with optional text.

See Also

Actions

Forum