Finding a Dynamic Menu Item -- Use KM Recorder

@ccstone here is my updated script

tell application "System Events"
   tell application process "Lightroom Classic"
      set its frontmost to true
      
      tell menu bar 1
         tell menu "File"
            perform action "AXPress"
            tell menu item "Plug-in Extras"
               perform action "AXPress"
               tell menu 1
                  return name of menu items
               end tell
            end tell
         end tell
      end tell	
   end tell
end tell

The output is

{"Aperture/iPhoto Importer Plug-in", " Import from Aperture Library...", " Aperture Import Info...", " Import from iPhoto Library...", " iPhoto Import Info...", "Aurora HDR 2018", " Transfer to Aurora HDR 2018", "DxO PhotoLab 2", " Transfer to DxO PhotoLab 2", "DxO PhotoLab 5", " Transfer to DxO PhotoLab 5", "Export to Photomatix Pro", " Export to Photomatix Pro...", "jf Flickr", " Flickr Extras...", "Luminar 3", " Transfer to Luminar 3", "Luminar 4", " Transfer to Luminar 4"}

I created a macro that looks like it should work

Alas, it failed:
2023-01-26 16:41:55 Menu selection failed to pick menu File➤Plug-in Extras➤ Flickr Extras... with error -5620. Macro “test” cancelled (while executing Select “ Flickr Extras...” in the Menu “File” in Lightroom Classic).

My guess is that @kikashi observation is happening here. The prefix to "Flickr Extras..." is not spaces but some other character...

Did you copy " Flickr Extras..." directly from the AppleScript output?

That should have been the exact text.

You can also try:

Three dots: ...

And

An ellipse character:

Opt-;

That sometimes makes all the difference.

I'd also try using a regular expression:

^.*Flickr Extras.*

@ccstone I did copy it directly from the output of the script. The original had 3 dots and did not work. I tried elipsis and regex, but same result :frowning:

Did you try the method which worked for me? Record in KM, then delete all but the menu choice line?

@kikashi I tried recording, but this is all I got:

@paulwaldo, that's bizarre. Perhaps there's a setting in KM which affects what it records (more knowledgeable head than mine can comment), or maybe you have a conflicting app somewhere on your Mac. When I first posted this solution, I was running (I think) Big Sur; I'm now running Ventura, with whatever the latest versions of KM and LR were and are. As I wrote yesterday (post #19 in this thread, I think - I don't know how to link to it), when I tried it again just now, recording worked perfectly.

Are you running something which might be interfering with KM's recording, perhaps?

@ccstone @kikashi Here is an interesting data point. I tried various KM Recorder actions in the Plug-in Extras menu. Some of them recorded properly in KM, like this

All of the ones that I want to record give simple mouse clicks like this

There is heavy Adobe Voodoo going on in that menu. Unfortunately well beyond my knowledge capability to understand it!

1 Like

I have no idea why, but now everything is working as it should. Both of these macros do exactly what they need to:

Note that when using explicit spaces (vs. regex), three spaces are necessary.

Thank you for your assistance @ccstone @kikashi!

1 Like

Glad you managed to get it working. I find that usually when something works, it's best not to worry too much about why.