MACRO: Go To Group by Name (Spotlight)

Sorry, Dan. I'm running KM9, but I have never installed your macro. I do use your "Go To Macro" macro, and it works fine under KM9.

FWIW, I have my own macro which uses AppleScript to go to a group. If anyone is interested, let me know and I will post.

1 Like

@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)

Chris @ccstone has devised a solution for this:

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

1 Like

Oh, well, that's just peachy. Are you having problems with things like KMFAM, or any of my other macros you use?

Nope. KMFAM is working great! This issue is only come up when you are using UI scripting.

1 Like

You say that like you think I remember how any of my stuff works. :stuck_out_tongue:

Thanks for the info.

Wood-working isn’t healthy for the brain :crazy_face:

I have a lifelong affliction called "CRS". It stands for "Can't Remember S....quat".

2 Likes

Yes, of course. after running it step by step, it reported the problem after this action. ▼

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.

It'd be great to have a new way to solve a problem I suppose. :smile:

Just disable the calls to the "Macro Scroll Position" macros. Everything else should work fine. Fingers crossed.

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.

Disable the action shown in the red box:

image

@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

--------------------------------------------------------------------------------

If you do, can you post it? Thanks.

Dan

1 Like

Dan, clearly I'm not Chris, but I gave you his solution earlier.

Replace:
tell window "Keyboard Maestro Editor"

With:
tell (first window whose subrole is "AXStandardWindow")

2 Likes

Thanks, Jim

@Alice_Shi - there's your answer, if you don't want to just disable it.

Thank you! Dan. I'm so happy It works again. I just can't image a day without this macro.

I have to say that I'm sorry for the confusion I've caused -- this reply → MACRO: Go To Group by Name (Spotlight) - Macro Library - Keyboard Maestro Discourse_2019-08-19 is base on 'Go to Macro by Name' instead of ''Go to Group by Name'. I was a little bit mix up. Maybe it's puzzled you.

No worries, I eventually figured it out. And being confused is a common state for me, anyway. :stuck_out_tongue:

Hey Folks

@ccstone ,@DanThomas ?

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

thanks in advance

Greetings from Germany

Tobias

Hey Tobias,

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

--------------------------------------------------------

Thank you Chris for this quick answer and the fix ...

The Macro is running like a charm !!!!!

Greetings from Germany

Tobias

1 Like

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?

Thanks,
Russell