User Tools

Site Tools


manual: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
Last revision Both sides next revision
manual:Tokens [2019/08/25 17:18]
JMichaelTX [Examples] Add link to macro
manual:Tokens [2021/10/04 02:44]
peternlewis [Text Case Conversions]
Line 1: Line 1:
 ====== Tokens ====== ====== Tokens ======
  
-**Keyboard Maestro provides two means to get information about objects (like web pages and windows) in the user's environment:​**+Keyboard Maestro provides two means to get information about objects (like web pages and windows) in the user's environment:​
  
 1. [[:​Tokens|Tokens]] (returns text, used in [[/​Text_Fields|text fields]]) 1. [[:​Tokens|Tokens]] (returns text, used in [[/​Text_Fields|text fields]])
 2. [[:​Functions|Functions]] (returns numbers, used in numeric fields ) 2. [[:​Functions|Functions]] (returns numbers, used in numeric fields )
  
-You can enter a Token in any [[/​Text_Fields|text field]] in an [[:​Actions|Action]],​ and when the Macro is triggered and the Action is executed, the token will be replaced by the value that is returned at run time.+You can enter a Token in any [[/​Text_Fields|text field]] in an [[:​Actions|Action]],​ and when the Macro is triggered and the Action is executed, the token will be replaced by the value that is returned at run time.  This allows you to easily combine static text with dynamic data that is supplied at run time, in most any Action that has a text field, like [[action:​Display_Text|Display Text]] and [[action:​Set_Variable_to_Text|Set Variable to Text]].
  
 ===== Token Format ===== ===== Token Format =====
Line 39: Line 39:
  
 The "​`[]()`"​ are just characters you type. The "​`[]()`"​ are just characters you type.
 +
 +After the macro and Action are executed, you will see this on the Clipboard:
 +
 +{{:​manual:​token-demo-display-clipboard.png?​nolink|}}
  
 That's all you need for a great macro, which you can [[https://​forum.keyboardmaestro.com/​t/​set-clipboard-to-markdown-link-of-frontmost-browser-wiki-example-macro-v9-0-1d2/​15025|download from here]]. That's all you need for a great macro, which you can [[https://​forum.keyboardmaestro.com/​t/​set-clipboard-to-markdown-link-of-frontmost-browser-wiki-example-macro-v9-0-1d2/​15025|download from here]].
Line 52: Line 56:
 * Just tokens (not backslashed characters) or  * Just tokens (not backslashed characters) or 
 * Do not process any text.  ​ * Do not process any text.  ​
- 
- 
-If you want to use the percent `%` character as a normal character, simply double the percent (`%%`). \\ 
-To use a backslash `\` in your text, double the backslash (`\\`). 
  
  
Line 62: Line 62:
 === Non-Printing Control Characters === === Non-Printing Control Characters ===
  
-An exception to the rule of enclosing Tokens in percent `%` characters, is the use of these Non-Printing Control Characters:\\ +An exception to the rule of enclosing Tokens in percent `%` characters, is the use of these Non-Printing Control Characters `\a,​\b,​\e,​\f,​\t,​\r,​\n` which correspond to (bell,​backspace,​escape,​form feed,​tab,​return,​line feed). ​ These will be replaced with their value in text fields, except for Regular Expression (RegEx) fields.
-`\a,​\b,​\e,​\f,​\t,​\r,​\n` ​\\ +
-which correspond to (bell,​backspace,​escape,​form feed,​tab,​return,​line feed).\\ +
-These will be replaced with their value in text fields, except for Regular Expression (RegEx) fields.+
  
 === Convert Hex to Unicode Characters === === Convert Hex to Unicode Characters ===
  
-Text token fields also process %NN% or %NNNN% or %NNNNNN% as arbitrary hex unicode characters (eg %41% is an A, %01F300% is 🌀), and (except for regular expression fields) .+Text token fields also process %NN% or %NNNN% or %NNNNNN% as arbitrary hex unicode characters (eg %41% is an A, %01F300% is 🌀).
  
 === Using Special Characters as Plain Text === === Using Special Characters as Plain Text ===
Line 78: Line 75:
 ===== Text Case Conversions ===== ===== Text Case Conversions =====
  
-Text fields also support ​(v9.0+) ​text case conversion using the below meta characters. You may use these in both standard Text Fields and in the Replace field of a [[action:​Search_and_Replace|Search and Replace by regular expression]] action (even though these meta characters are _not_ supported by ICS Regular Expressions).+Text fields also support text case conversion using the below meta characters. You may use these in both standard Text Fields and in the Replace field of a [[action:​Search_and_Replace|Search and Replace by regular expression]] action (even though these meta characters are _not_ supported by ICS Regular Expressions).
  
 The Available Case Conversion Meta Characters are: The Available Case Conversion Meta Characters are:
Line 96: Line 93:
 With tokens that return a list of information (comma separated by default), you can access the individual items using the Variable array notation, append the item number in square brackets `[ ]` to the Token name, just before the closing `%`. With tokens that return a list of information (comma separated by default), you can access the individual items using the Variable array notation, append the item number in square brackets `[ ]` to the Token name, just before the closing `%`.
  
-For example:\\+For example: 
 Token for Window Frame, [[token:​WindowFrame | %WindowFrame[3]%1%]],​ will be the third comma-separated value, which is the Window width in this case. Token for Window Frame, [[token:​WindowFrame | %WindowFrame[3]%1%]],​ will be the third comma-separated value, which is the Window width in this case.
  
manual/Tokens.txt · Last modified: 2023/10/02 00:10 by peternlewis