User Tools

Site Tools


Text_Fields

**This is an old revision of the document!**

Text Fields

Keyboard Maestro has two very distinct types of fields: text fields and numeric fields. Most text fields are text token fields. Most numeric fields are calculation fields.

Numeric Fields

Numeric fields start out small, and usually have double arrows stepper next to them:

 Small Stepper Numeric Field

and then expand to allow more text if you type something other than a simple number:

 Expanded Numeric Field

They are designed to allow you to enter a specific numeric value. In these fields, you can type a raw calculation, which can include variables and functions. Eg “Count + 2 * DOW()”. To use a variable in a numeric field, you use it as is, without any adornment.

As soon as you type anything other than a digit, they expand to a larger size to allow for a calculation. Calculation fields never use percent text tokens.

If the function is invalid, it will highlight in red. Keep in mind that the expression may be invalid simply because a variable it references does not yet have a value. If you have not set the Count variable to a value, then the above action would look like this:

 Error Numeric Field

This is nothing inherently wrong with the action - the variable Count just does not currently have a numeric value. Expressions that are invalid only because a variable is not currently valid will show in orange instead of red.

You can insert functions into numeric fields using the Edit ➤ Insert Function menu. If you hold the option key down while selecting a function, you will get help on that function (from this wiki).

Text Fields

Text fields, on the other hand, start out larger. They may be single line, or multi-line, and may expand to more lines to fit (within limits) the content. Text token fields process text tokens which are marked with percents, like %CurrentClipboard% or %Variable%My Variable% and typically (but not always) have an Insert Token pull down menu. They also process backslash characters (eg \r, \n, \t, etc) (except in regular expression fields). Text fields can include the values of variables by using the Variable token, eg:

You can use a calculation in a text field using the Calculate text token, eg %Calculate%1+2%.

You can insert text tokens into text fields using the Edit ➤ Insert Token menu. If you hold the option key down while selecting a token, you will get help on that token (from this wiki).

Text token fields also process %NN% or %NNNN% as arbitrary hex unicode characters (eg %41% is an A), and (except for regular expression fields) process backslashed characters \a,\b,\e,\f,\t,\r,\n (bell,backspace,escape,form feed,tab,return,line feed).

To include a percent in your text, simply double the percent (%%). To include a backslash \ in your text, double the backslash (\\).

Text Case Conversions

Text token fields also support (v9.0+) text case conversion escapes. The most common use is to change the case of an interpolated variable or other token, as well as in Search and Replace by regular expression action. The conversion escape codes are:

  • \U converts everything up to the next \L or \E to uppercase.
  • \L converts everything up to the next \U or \E to lowercase.
  • \u converts the next character to uppercase.
  • \l converts the next character to lowercase.
  • \U\l lowercase first, then uppercase.
  • \L\u uppercase first, then lowercase.
  • \E stop changing case.

You should not use \u after \U or \l after \L unless you terminate the sequence with \E first.

Script Fields

Almost every field in Keyboard Maestro actions is either a numeric field or a text token field. The major exceptions are script fields. Scripts are not processed for text tokens, they must access variables through other means.

See Also

Tokens

Topics

Forum

Text_Fields.1561466713.txt.gz · Last modified: 2019/06/25 08:45 by peternlewis