Scripting_the_Keyboard_Maestro_editor
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| Scripting_the_Keyboard_Maestro_editor [2017/10/14 02:07] – Move script for Macro Groups to here JMichaelTX | Scripting_the_Keyboard_Maestro_editor [2018/04/14 23:02] (current) – Removed script from Section 4 because it won't even compile. JMichaelTX | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| FIXME Just adding this until I can provide a more complete script. | FIXME Just adding this until I can provide a more complete script. | ||
| - | ===== Selecting Lists of Objects in KM8 ===== | + | ===== 1. Selecting Lists of Objects in KM8 ===== |
| + | |||
| + | The `selection` property will return whatever is selected, and has focus, in the Keyboard Maestro editor. | ||
| + | |||
| + | ```applescript | ||
| + | tell application " | ||
| + | |||
| + | --- First Select an Action, Macro, or Macro Group | ||
| + | -- in the KM Editor, then run this script | ||
| + | |||
| + | set kmList to selection | ||
| + | set kmClass to class of item 1 of kmList | ||
| + | |||
| + | -->Based on selection, will return one of these: | ||
| + | --> | ||
| + | |||
| + | end tell | ||
| + | |||
| + | ``` | ||
| ```applescript | ```applescript | ||
| Line 18: | Line 37: | ||
| - | ===== 1. Get Current Macro Object ===== | + | ===== 2. Get Current Macro Object ===== |
| ```applescript | ```applescript | ||
| Line 44: | Line 63: | ||
| ``` | ``` | ||
| - | ===== 2. Macro Groups ===== | + | ===== 3. Macro Groups ===== |
| **Disable a Macro Group** | **Disable a Macro Group** | ||
| Line 70: | Line 89: | ||
| </ | </ | ||
| - | ===== 3. Get and Create Variety of Editor Objects ===== | + | ===== 4. Get and Create Variety of Editor Objects ===== |
| + | FIXME [JMichaelTX: | ||
| - | ```applescript | ||
| - | tell app " | ||
| - | | + | ===== 5. Create Macro Group and Macros ===== |
| - | | + | |
| - | make new smart group with properties {name:" | + | Before you use a macro group you probably want to check if it exists. The following example tests for the macro group's existence, based on a Keyboard Maestro input variable containing the macro group name -`macroGroup`. |
| - | set search strings of smart group " | + | |
| - | + | ||
| - | set enable of macro group "Turn Off" to false | + | |
| - | set name of macro 1 to "Great!" | + | (This test is case-insensitive. For example |
| - | tell macro group "New Stuff" | + | ```applescript |
| - | + | tell application | |
| - | set color of action 1 of macro " | + | set macroGroup |
| - | + | if (macroGroup = "" | |
| - | | + | end tell |
| - | set selection to global macro group | + | tell application |
| - | + | if exists | |
| - | move first action of macro "Source Macro" to end of actions of macro "Dest Macro" | + | |
| - | + | else | |
| - | move macro " | + | |
| - | move (every macro of macro group " | + | |
| - | move macro 2 of macro group " | + | |
| - | + | ||
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | set m to duplicate action 1 of macro " | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| end tell | end tell | ||
| ``` | ``` | ||
| - | ===== 4. Create Macro Group and Macros ===== | ||
| Here is a full example that creates a macro group called " | Here is a full example that creates a macro group called " | ||
Scripting_the_Keyboard_Maestro_editor.1507946862.txt.gz · Last modified: by JMichaelTX
