manual:Tokens
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| manual:Tokens [2019/06/17 07:25] – peternlewis | manual:Tokens [2023/10/02 04:10] (current) – peternlewis | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Tokens ====== | ====== Tokens ====== | ||
| - | Tokens allow you to add textual | + | Keyboard Maestro provides two means to get information |
| - | You can insert tokens into a field using the Insert Token popup near the field or by choosing | + | 1. [[:Tokens|Tokens]] (returns text, used in [[/ |
| + | 2. [[:Functions|Functions]] (returns numbers, used in [[/ | ||
| - | The available tokens are listed on the [[/Tokens|wiki Tokens page]]. | + | You can enter a Token in any [[/Text_Fields|text field]] in an [[: |
| - | Text token fields also process | + | ===== Token Format ===== |
| + | |||
| + | Tokens are identified by a pair of percent `%` symbols at the start and end of the Token name. | ||
| + | |||
| + | ^ Usage ^ Format ^ Example ^ Token\\ Results ^ | ||
| + | | No Parameter | `%TokenName%` | Safari open to this web page:\\ [[https:// | ||
| + | | With Parameter | `%TokenName%Parameter%` | Frontmost Window Size | [[token: | ||
| + | |||
| + | ===== Entering Tokens into Actions ===== | ||
| + | |||
| + | The available tokens, and their definitions, | ||
| + | |||
| + | When you are editing a Macro, put the text cursor in a text field, and do one of the following to select and insert a Token into the text field. | ||
| + | |||
| + | 1. Press ⌘⌃T (or use the Menu) to display a prompt to select the Token by Name | ||
| + | 2. Use the [[Menus# | ||
| + | 3. Click on the " | ||
| + | 4. Of course, you can always just type the Token. | ||
| + | |||
| + | You can tell that a text field accepts tokens because a small BUTTON{{{T}}} shows in the field while editing it. | ||
| + | |||
| + | ===== Examples ===== | ||
| + | |||
| + | Let's look at a real-world example. | ||
| + | |||
| + | 1. [[token: | ||
| + | 2. [[token: | ||
| + | |||
| + | {{ token-example-set-clipboard.png? | ||
| + | |||
| + | The "`[]()`" are just characters you type, part of the markdown text and not part of the tokens. | ||
| + | |||
| + | 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:// | ||
| + | |||
| + | That's all you need for a great macro, which you can create yourself or [[https:// | ||
| + | |||
| + | |||
| + | ===== Processing ===== | ||
| + | |||
| + | 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: | ||
| + | |||
| + | * Process tokens normally, or | ||
| + | * Just tokens (not backslashed characters) or | ||
| + | * Do not process | ||
| + | |||
| + | ===== Other Uses for Tokens ===== | ||
| + | |||
| + | === 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, | ||
| + | |||
| + | === 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 🌀). | ||
| + | |||
| + | === Using Special Characters as Plain Text === | ||
| To include a percent in your text, simply double the percent (%%). To include a backslash \ in your text, double the backslash (\\). | To include a percent in your text, simply double the percent (%%). To include a backslash \ in your text, double the backslash (\\). | ||
| - | With tokens that commonly contain arrays | + | |
| + | ===== Text Case Conversions ===== | ||
| + | |||
| + | 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: | ||
| + | |||
| + | The Available Case Conversion Meta Characters 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. | ||
| + | |||
| + | ==== Access to an Item in Token Results ==== | ||
| + | |||
| + | With tokens that return a list of information | ||
| + | |||
| + | For example: | ||
| + | |||
| + | Token for Window Frame, [[token: | ||
| + | |||
| + | * %WindowFrame%1% returns " | ||
| + | * %WindowFrame[3]%1% returns " | ||
| + | |||
| + | Some tokens | ||
| * [[token: | * [[token: | ||
| Line 23: | Line 111: | ||
| * [[token: | * [[token: | ||
| * [[token: | * [[token: | ||
| - | |||
| - | Many actions allow you to turn off tokens or backslash character processing if you need to use text that has percent or backslash characters. | ||
| - | |||
manual/Tokens.1560756356.txt.gz · Last modified: by peternlewis
