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/08/31 05:16]
peternlewis
Scripting_the_Keyboard_Maestro_editor [2017/09/20 16:41]
JMichaelTX [1. Get Current Macro Object] Revise script
Line 4: Line 4:
  
 The Keyboard Maestro Scripting Definition (sdef) describes all the support, and you can open in in the Script Editor to see more details. ​ Here are some examples of what you can do: The Keyboard Maestro Scripting Definition (sdef) describes all the support, and you can open in in the Script Editor to see more details. ​ Here are some examples of what you can do:
 +
 +===== 1. Get Current Macro Object =====
 +
 +```applescript
 +
 +tell application "​Keyboard Maestro"​
 +  #    Ver 1.1    2017-09-20
 +  ​
 +  set macroList to every macro whose selected is true
 +  ​
 +  --- Make Sure Only ONE Macro is Selected ---
 +  ​
 +  if ((count of macroList) = 1) then
 +    set oMacro to first macro whose selected is true
 +  else
 +    error "​Multiple Macros are selected. ​ Select only ONE and re-execute this script."​
 +  end if
 +  ​
 +  --- Now We can Get/Set Macro Properties ---
 +  ​
 +  set macroName to name of oMacro
 +  ​
 +  return macroName
 +  ​
 +end tell
 +```
 +
 +
 +===== 2. Get and Create Variety of Editor Objects =====
 +
  
 ```applescript ```applescript
Line 42: Line 72:
 end tell end tell
 ``` ```
 +
 +===== 3. Create Macro Group and Macros =====
  
 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"
Line 96: Line 128:
 end tell end tell
 ``` ```
 +
 +You can get XML by creating sample macros and then using the Copy as XML in the Edit menu.
 +
Scripting_the_Keyboard_Maestro_editor.txt ยท Last modified: 2018/04/14 19:02 by JMichaelTX