User Tools

Site Tools


Scripting_the_Keyboard_Maestro_editor

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
Next revision Both sides next revision
Scripting_the_Keyboard_Maestro_editor [2017/12/14 21:54]
JMichaelTX ADD script to get class of object selected
Scripting_the_Keyboard_Maestro_editor [2018/04/14 10:43]
MartinPacker [5. Create Macro Group and Macros]
Line 9: Line 9:
 ===== 1. 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.  So this could be any of these: ​ action, macro, macro group. ​ Here is how to get the selection, and determine the type (class) of the object that is selected:+The `selection` property will return whatever is selected, and has focus, in the Keyboard Maestro ​editor.  So this could be any of these: ​ action, macro, macro group. ​ Here is how to get the selection, and determine the type (class) of the object that is selected:
  
 ```applescript ```applescript
Line 131: Line 131:
  
 ===== 5. Create Macro Group and Macros ===== ===== 5. Create Macro Group and Macros =====
 +
 +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`.
 +
 +(This test is case-insensitive. For example macro group "​Firefox"​ could also be specified as "​firefox"​.)
 +
 +```applescript
 +tell application "​Keyboard Maestro Engine"​
 + set macroGroup to getvariable "​macroGroup"​
 +end tell
 +
 +tell application id "​com.stairways.keyboardmaestro.editor"​
 + if exists macro group macroGroup then
 + return true
 + else
 + return false
 + end if
 +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"
Scripting_the_Keyboard_Maestro_editor.txt ยท Last modified: 2018/04/14 19:02 by JMichaelTX