@DanThomas, I suspect this is due to the fact that in KM9 the KM Editor window name/title has changed. For example, it now looks like this: Keyboard Maestro Editor — Go To Macro by Name (Spotlight) (Author.@DanThomas)
tell application "System Events"
tell application process "Keyboard Maestro"
set frontmost to true
tell (first window whose subrole is "AXStandardWindow")
### YOUR CODE HERE ###
end tell
end tell
end tell
This action is in a sub-macro named Macro Scroll Position - Store for Current Macro (Sub-Macro), and the popup error message is the same as what I've posted before ▼
Macro Scroll Position - Store for Current Macro (Sub-Macro)
An error has occurred: System Events got an error: Can't get window "Keyboard Maestro Editor" of process "Keyboard Maestro".
BTW, the same error reoccurred even if reinstalling this macro.
That works for the macro Go To Macro by Name (Spotlight). But doesn't work for the macro Go To Group by Name (Spotlight), Actually, the latter doesn't involve "Macro Scroll Position" macro as a sub-macro. When you run it, It can perfectly take you to the macro group you wanted to go, but it has been keeping popping up the error as I described before.
@ccstone: I believe you have a workaround for this code?
--------------------------------------------------------------------------------
# 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
--------------------------------------------------------------------------------
I am stuck .... I made the chages which were described by Jim in post #34 to get rid of applescript Error Num -10006 .
I now getting this Error:
„System Events“ hat einen Fehler erhalten: „window 1 of application process "Keyboard Maestro" whose subrole = "AXStandartWindow"“ kann nicht gelesen werden. Ungültiger Index.
Num: -1719
How con this be fixed?
here is Chris' AppleScript code with the changes I made:
--------------------------------------------------------------------------------
# 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"
-- Use lte line below in older Versions of KM
-- tell window "Keyboard Maestro Editor"
set frontmost to true
tell (first window whose subrole is "AXStandartWindow")
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
--------------------------------------------------------------------------------
I am using KM 9.2 on High Sierra 10.13.6 and on Catalina 10.15.7
This should work with either Keyboard Maestro 9 or 10.
-Chris
--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2015/07/25 03:06
# dMod: 2021/12/23 17:21
# Appl: Keyboard Maestro & System Events
# Task: Set Focus to Macro List (KM 9 & 10)
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Keyboard_Maestro, @Focus, @Macro_List
--------------------------------------------------------
tell application "Keyboard Maestro" to ¬
set kmVersion to its version
if kmVersion starts with "9" then -- Keyboard Maestro 9.x
tell application "System Events"
tell application process "Keyboard Maestro"
set frontmost to true
tell (first window whose subrole is "AXStandardWindow")
tell group 1
tell splitter group 1
tell scroll area 2
set focused to true
end tell
end tell
end tell
end tell
end tell
end tell
else if kmVersion starts with "10" then -- Keyboard Maestro 10.x
tell application "System Events"
tell application process "Keyboard Maestro"
set frontmost to true
tell (first window whose subrole is "AXStandardWindow")
tell group 6
tell splitter group 1
tell scroll area 2
set focused to true
end tell
end tell
end tell
end tell
end tell
end tell
end if
--------------------------------------------------------
This is quite useful, and is working great. But I don't understand the need for the "Spotlight Search Prompt" macro group. Go to Group by Name works fine with this group disabled. And all the examples involving "Dictionary," "Custom Buttons" json, etc. What's that all about?
Did the installation just use some small part of the Spotlight Search Prompt group on a one-time basis? Can I remove this group?