User Tools

Site Tools


Tokens

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Tokens [2016/12/02 04:43]
peternlewis
Tokens [2020/08/17 21:27]
peternlewis [Text Processing]
Line 1: Line 1:
-{{:​token-icon.png?​nolink|}} 
 ====== Tokens ====== ====== Tokens ======
  
 ===== Definition ===== ===== Definition =====
  
-**Tokens in Keyboard Maestro represent placeholders for information ​about a specific object.** For example, the [[token:​SafariTitle|%SafariTitle% token]] ​returns ​the title of the current Safari tab.  So the value of the Token will be determined at execution time.  All tokens return a text value, even if the source data was some other data type.+**Tokens in Keyboard Maestro represent placeholders, that you enter during design time, for information ​that will be replaced in the text at run time.** For example, ​you could enter the [[token:​SafariTitle|%SafariTitle% token]] ​in a [[action:​Set_Variable_to_Text|Set Variable to Text Action]], and when you trigger the macro it will be replaced with the title of the current Safari tab.  So the value of the Token will be determined at execution time.  All tokens return a text value, even if the source data was some other data type.
  
 Tokens allow you to add textual information to [[/​Text_Fields|token text fields]]. ​ You can insert tokens into a field using the Insert Token popup near the field or by choosing [[manual:​Menus#​Edit_Insert_Token|Insert Token]] from the [[manual:​Menus#​Edit|Edit menu]]. ​ You can also start typing a token and use text completion to complete the token. Tokens allow you to add textual information to [[/​Text_Fields|token text fields]]. ​ You can insert tokens into a field using the Insert Token popup near the field or by choosing [[manual:​Menus#​Edit_Insert_Token|Insert Token]] from the [[manual:​Menus#​Edit|Edit menu]]. ​ You can also start typing a token and use text completion to complete the token.
  
-Text token fields also process ​%NN% or %NNNN% as arbitrary hex unicode ​characters (eg %41% is an A)and (except for regular expression fieldsprocess backslashed characters ​\a,\b,\e,\f,\t,\r,\n (bell,​backspace,​escape,​form feed,​tab,​return,​line feed).+===== Text Processing ===== 
 + 
 +You can use the following special formats to process ​text or to return non-printing ​characters
 +  * **Convert Case of Text** 
 +    * Use these special characters: ​ `\U  \L  \E  \u  \l` (for detailssee [[manual:​Tokens#​Text_Case_Conversions|Text Case Conversions]])
 +  * **Return Non-Printing Characters** 
 +    * **Convert**:​ `\a \b \e \f \t \r \n
 +    * **To**: `bell, backspace, escape, form feed, tab, return, line feed`. 
 +  * **Convert Hex Code to Unicode Characters** 
 +    * Use Hex Codes in this format: `%NN%` or `%NNNN%` 
 +  * **Escape Special Characters** 
 +    * Use `%%` or `\%` to return a single `%` as plain text. 
 +    * Use `\\` to return a single `\` as plain text. 
 +    * Use `\$` to return a single `$` as plain text. 
 +  * **Access replacement strings** 
 +    * Replacement strings can also have addition meanings (such as `\1` or `${3}`)
  
-To include a percent in your text, simply double the percent. To include a backslash in your text, double the backslash. 
  
  
Tokens.txt · Last modified: 2020/08/17 21:27 by peternlewis