UPDATED 2023/02/01 05:15 CDT
- When Keyboard Maestro was released the KM Editor itself wasn't very AppleScriptable, and it was necessary to use UI-Scripting or KM itself to automate it.
- Posts #1 through #35 represent largely older methods of manipulating the editor.
- With the release of Keyboard Maestro 8, some of these techniques have been superseded by more direct scripting methods as Peter has improved the KM Editor's AppleScript dictionary.
- Other useful topics on the forum:
- 2022/12/16 14:08 CDT
- See Post #37 and after for content specific to Keyboard Maestro Editors v9.x & v10.x.
- 2023/02/01 03:32 CDT
- I will try to spend some time modernizing this thread in the near future. @ccstone
[This thread is pending revision.]
Hey Folks,
Three AppleScripts to make navigating in the Keyboard Maestro Editor a little easier.
All of these should be run from an Execute an AppleScript action, and they will run a bit faster if run as compiled-scripts rather than as text-scripts.
Move Focus to Group List
--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2015/07/25 03:06
# dMod: 2015/07/25 03:19
# Appl: Keyboard Maestro & System Events
# Task: Set Focus to Group List
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Keyboard_Maestro, @Focus, @Group_List
--------------------------------------------------------------------------------
try
tell application "System Events"
tell application process "Keyboard Maestro"
tell window "Keyboard Maestro Editor"
tell scroll area 1 of splitter group 1 of group 1
set focused to true
end tell
end tell
end tell
end tell
on error e number n
set e to e & return & return & "Num: " & n
if n ≠-128 then
try
tell application (path to frontmost application as text) to set ddButton to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy Error Message" then set the clipboard to e
end try
end if
end try
--------------------------------------------------------------------------------
Move Focus to Macro List
--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2015/07/25 03:06
# dMod: 2015/07/25 03:14
# Appl: Keyboard Maestro & System Events
# Task: Set Focus to Macro List
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Keyboard_Maestro, @Focus, @Macro_List
--------------------------------------------------------------------------------
try
tell application "System Events"
tell application process "Keyboard Maestro"
tell window "Keyboard Maestro Editor"
tell scroll area 2 of splitter group 1 of group 1
set focused to true
end tell
end tell
end tell
end tell
on error e number n
set e to e & return & return & "Num: " & n
if n ≠-128 then
try
tell application (path to frontmost application as text) to set ddButton to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy Error Message" then set the clipboard to e
end try
end if
end try
--------------------------------------------------------------------------------
Move Focus to Group or Macro Name Field
--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2015/07/25 03:06
# dMod: 2016/06/21 18:10
# Appl: Keyboard Maestro & System Events
# Task: Select Macro or Group Name Field for Editing
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Keyboard_Maestro, @Select, @Name, @Field
--------------------------------------------------------------------------------
try
tell application "System Events"
tell application process "Keyboard Maestro"
tell menu item "Start Editing Macros" of menu "View" of menu bar item "View" of menu bar 1
if it exists then click it
end tell
tell window "Keyboard Maestro Editor"
tell scroll area 3 of splitter group 1 of group 1
if text field 1 exists then
tell (first text field whose attribute "AXPlaceholderValue"'s value is "macro name")
set focused to true
# perform action "AXShowMenu"
end tell
end if
end tell
end tell
end tell
end tell
on error e number n
set e to e & return & return & "Num: " & n
if n ≠-128 then
try
tell application (path to frontmost application as text) to set ddButton to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy Error Message" then set the clipboard to e
end try
end if
end try
--------------------------------------------------------------------------------
-Chris