by MODERATOR -- 2018-07-29 17:08 GMT-5
[This thread is pending revision.]
Chris and others provided some great scripts/macros in this thread back in the day when UI scripting was needed to control the Keyboard Maestro Editor.
With the release of Keyboard Maestro 8, some of these are obsolete, and should be deprecated.
As of KM 8, it is much easier, and more reliable, to use the new scripting commands/objects.
For more info, see
- Scripting the Keyboard Maestro editor - KM Wiki.
- All Topics Tagged with "KM8+AppleScript" and "Editor" in Title
- KM8: Accessing and Controlling the Keyboard Maestro Editor
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