I have this applescript that @ccstone kindly shared at some point, can't find original thread now.
----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2019/01/25 06:15
# dMod: 2019/01/25 07:07
# Appl: Keyboard Maestro
# Task: Create and Select a New Global Macro in Group "Global Macro Group"
# : then Select the Macro Name Field .
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Keyboard_Maestro, @Create, @Select, @New, @Global, @Macro, @Name, @Field
----------------------------------------------------------------
try
tell application "Keyboard Maestro"
activate
tell macro group "Global Macro Group"
set newMacro to make new macro with properties {name:"New Global Macro"}
end tell
select macro group "Global Macro Group"
select newMacro
end tell
tell application "System Events"
tell application process "Keyboard Maestro"
tell window "Keyboard Maestro Editor"
tell group 1
tell splitter group 1
tell scroll area 3
tell scroll bar 1
if value ≠ 0 then set value to 0
end tell
if exists (first text field whose accessibility description is "Macro Group Name") then
tell (first text field whose accessibility description is "Macro Group Name")
set focused to true
end tell
else
tell (first text field whose accessibility description is "Macro Name")
set focused to true
end tell
end if
end tell
end tell
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
----------------------------------------------------------------
Which I ran like so:
The problem is that although it works, every time it throws this error:
System Events got an error: Can’t get window "Keyboard Maestro Editor" of application process "Keyboard Maestro".
Num: -1728
I tried ask GPT-4, it seems maybe KM window name changed?