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/07/01 05:07] – 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 |
| - | For example, `%SystemClipboard%` will be replaced by the text in the clipboard. | + | 1. [[: |
| + | 2. [[: | ||
| - | You can insert tokens into a field using the Insert | + | You can enter a Token in any [[/ |
| - | The available tokens are listed on the [[/ | + | ===== Token Format ===== |
| - | ==== Processing ==== | + | Tokens are identified by a pair of percent `%` symbols at the start and end of the Token name. |
| - | Text token fields also process | + | ^ 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 (\\). | ||
| - | In most text fields, you can select (in the BUTTON{{{⚙}}} menu) whether to process tokens normally, or just tokens (not backslashed characters) or do no text processing at all. Alternatively, | ||
| - | ==== Text Case Conversions ==== | + | ===== Text Case Conversions |
| - | Text token fields also support | + | Text fields also support text case conversion |
| + | |||
| + | The Available Case Conversion Meta Characters | ||
| * `\U` converts everything up to the next `\L` or `\E` to uppercase. | * `\U` converts everything up to the next `\L` or `\E` to uppercase. | ||
| Line 31: | Line 88: | ||
| You should not use `\u` after `\U` or `\l` after `\L` unless you terminate the sequence with `\E` first. | You should not use `\u` after `\U` or `\l` after `\L` unless you terminate the sequence with `\E` first. | ||
| - | ==== Arrays | + | ==== Access to an Item in Token Results |
| + | |||
| + | 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: | ||
| + | |||
| + | Token for Window Frame, [[token: | ||
| + | |||
| + | * %WindowFrame%1% returns " | ||
| + | * %WindowFrame[3]%1% returns " | ||
| - | With tokens that commonly contain arrays of information, | + | Some tokens that allow indexing include: |
| * [[token: | * [[token: | ||
manual/Tokens.1561957646.txt.gz · Last modified: by peternlewis
