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
manual:Tokens [2019/08/26 11:22]
JMichaelTX ADD statement about combining Tokens with Static Text
manual:Tokens [2023/10/02 00:10] (current)
peternlewis
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 ​token fields]]) 
-2. [[:​Functions|Functions]] (returns numbers, used in numeric fields )+2. [[:​Functions|Functions]] (returns numbers, used in [[/​Text_Fields|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.  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]].+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 that time.  This allows you to easily combine static text with dynamic data that is supplied ​when the macro is executed, 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]] ​actions.
  
 ===== Token Format ===== ===== Token Format =====
Line 23: Line 23:
  
 1. Press ⌘⌃T (or use the Menu) to display a prompt to select the Token by Name 1. Press ⌘⌃T (or use the Menu) to display a prompt to select the Token by Name
-2. GoTo menu [[Menus#​Insert_Token|Edit ➤ Insert Token menu]]+2. Use the [[Menus#​Insert_Token|Edit ➤ Insert Token menu]]
 3. Click on the "​Insert Token" popup at the top right of the text fields to see the same menu as in #2. 3. Click on the "​Insert Token" popup at the top right of the text fields to see the same menu as in #2.
 4. Of course, you can always just type the Token. 4. Of course, you can always just type the Token.
Line 33: Line 33:
 Let's look at a real-world example. ​ Let's say you would like to set the Clipboard to a [[https://​www.markdownguide.org/​basic-syntax/#​links | Markdown Link]] of the current web page you are reading. ​ All you need to do is insert these two tokens (using the Markdown format) in a [[action:​Set_Clipboard_to_Text|Set Clipboard]] Action: Let's look at a real-world example. ​ Let's say you would like to set the Clipboard to a [[https://​www.markdownguide.org/​basic-syntax/#​links | Markdown Link]] of the current web page you are reading. ​ All you need to do is insert these two tokens (using the Markdown format) in a [[action:​Set_Clipboard_to_Text|Set Clipboard]] Action:
  
-1. `%FrontBrowserTitle%` +1. [[token:​FrontBrowserTitle|%FrontBrowserTitle%]] 
-2. `%FrontBrowserURL%`+2. [[token:​FrontBrowserURL|%FrontBrowserURL%]]
  
-{{:manual:token-example-set-clipboard.png?​nolink|}}+{{ token-example-set-clipboard.png?​nolink&​424x174 ​Token Example ​}}
  
-The "​`[]()`"​ are just characters you type.+The "​`[]()`"​ are just characters you type, part of the markdown text and not part of the tokens.
  
-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]].+After the macro and Action are executed, you will see something like this on the Clipboard:​ 
 + 
 +    [Keyboard Maestro: Work Faster with Macros for macOS](https://​www.keyboardmaestro.com/​main/​) 
 + 
 +That's all you need for a great macro, which you can create yourself or  ​[[https://​forum.keyboardmaestro.com/​t/​set-clipboard-to-markdown-link-of-frontmost-browser-wiki-example-macro-v9-0-1d2/​15025|download from here]].
  
  
 ===== Processing ===== ===== Processing =====
  
-The Tokens are processed, that is replaced by their value at run time, when the Macro is run, and the Action containing the Token is executed.+The Tokens are processed, that is replaced by their value when the action ​is run, and the Action containing the Token is executed.
  
 In most text fields, you can control how Tokens are processed using the Gear BUTTON{{{⚙}}} popup menu: In most text fields, you can control how Tokens are processed using the Gear BUTTON{{{⚙}}} popup menu:
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 (`\\`). 
- 
  
 ===== Other Uses for Tokens ===== ===== Other Uses for Tokens =====
Line 62: Line 61:
 === 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 74:
 ===== 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 92:
 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.
  
Line 102: Line 99:
 * %WindowFrame[3]%1% returns "​1514"​ * %WindowFrame[3]%1% returns "​1514"​
  
-These tokens allow this indexing:+Some tokens ​that allow indexing ​include:
  
 * [[token:​TriggerValue|TriggerValue]] * [[token:​TriggerValue|TriggerValue]]
manual/Tokens.1566832938.txt.gz · Last modified: 2019/08/26 11:22 by JMichaelTX