This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Last revision Both sides next revision | ||
Scripting_the_Keyboard_Maestro_editor [2018/04/14 10:43] MartinPacker [5. Create Macro Group and Macros] |
Scripting_the_Keyboard_Maestro_editor [2018/04/14 18:46] JMichaelTX [5. Create Macro Group and Macros] Added error checking to Example 5 Test for Macro Group existence. |
||
---|---|---|---|
Line 138: | Line 138: | ||
```applescript | ```applescript | ||
tell application "Keyboard Maestro Engine" | tell application "Keyboard Maestro Engine" | ||
- | set macroGroup to getvariable "macroGroup" | + | set macroGroup to getvariable "macroGroup" |
+ | if (macroGroup = "") then error "[ERROR]" & linefeed & "Invalid Macro Group Name. KM Variable \"" & "macroGroup" & "\" was empty or undefined." | ||
end tell | end tell | ||
- | tell application id "com.stairways.keyboardmaestro.editor" | + | tell application "Keyboard Maestro" -- Editor |
- | if exists macro group macroGroup then | + | if exists macro group macroGroup then |
- | return true | + | return true |
- | else | + | else |
- | return false | + | return false |
- | end if | + | end if |
end tell | end tell | ||
- | |||
``` | ``` | ||
+ | |||
Here is a full example that creates a macro group called "Multiple Clipboards" and then creates 9 macros with hot Control-C and action to copy the clipboard to a named clipboard with name "Clipboard N" (where N is 1-9) and another set of 9 macros with hot key Control-V and action to paste from the named clipboard "Clipboard N" | Here is a full example that creates a macro group called "Multiple Clipboards" and then creates 9 macros with hot Control-C and action to copy the clipboard to a named clipboard with name "Clipboard N" (where N is 1-9) and another set of 9 macros with hot key Control-V and action to paste from the named clipboard "Clipboard N" |