New Stream Deck version broke my AppleScript

A few months ago, someone on the Keyboard Maestro forum pointed me to this macro for selecting a Stream Deck profile from the menu bar. The new 6.4.1 version of SD changed its menu structure, so the profile names have moved one level further down.

How do I modify the AppleScript to account for this second-level menu? Thanks!

Old version menu:

New version menu:

You haven’t actually specified what it is - no specific reference, no link, no code… :frowning:

I am going to guess it might be related to one of your previous topics - but I could be entirely wrong, and I remember that thread just leaving me with questions.

Can you provide the exact details of what you are currently using, how you are triggering, etc?

Sorry… Here’s the AppleScript code. I trigger it from Stream Deck. Its function is to change both the Adobe Lightroom interface (go to the Library module) AND change the SD profile to display buttons for Library commands.

And yes, it’s related to my past queries about returning to the previous SD profile. It was all working fine until Elgato changed the interface. I think the issue is in the “tell menu 1 of menu bar item 1 of menu bar 2” line. I’m searching, but still haven’t found an explanation of how AS counts menu bars…

I think it needs another level, like:
tell menu 1 of menu bar item [?] of menu bar item 1 of menu bar 2

But so far, I haven’t hit on it…

UI Browser says this is the element path all the way down to the item I want to click:

From this, I constructed:
tell menu 1 of menu item “Stream Deck XL” of menu 1 of menu bar item 1 of menu bar 2

But it doesn’t work. Am I getting close?

Thanks,
Russell

1 Like

I’m making some progress, with the help of the app UI Browser, which describes the element path like this:

Based on this, I wrote this script, which displays the second-level “Stream Deck XL” menu, showing the list of Stream Deck profiles:

tell application "System Events"
	tell process "Stream Deck"
		click menu bar item 1 of menu bar 2
		delay 0.1 -- give it time to draw menu
		click menu item 7 of menu 1 of menu bar item 1 of menu bar 2
	end tell
end tell

(Interesting that while menu item “Stream Deck XL” didn’t work, using “menu item 7” did work.)

Now, I need to click an item (LR-Home) on that list of profiles. So, I modified the above script like this, based on the UI Browser’s element path:

tell application "System Events"
	tell process "Stream Deck"
		click menu bar item 1 of menu bar 2
		delay 0.5 -- give it time to draw menu
		click menu item "LR-Home" of menu 1 of menu item 7 of menu 1 of menu bar item 1 of menu bar 2
	end tell
end tell

There must be something about the new Stream Deck version that’s preventing normal Applescript UI scripting from working. :frowning:

Do you know of any way to have AppleScript click an item in a menu what is currently displayed?

Thanks,
Russell

In case anyone’s following this, the problem was solved by a smart person on Late Night Software’s Script Debugger forum:

tell application "System Events"
	tell process "Stream Deck"
		click menu bar item 1 of menu bar 2
		delay 0.5 -- give it time to draw menu
		click menu item 7 of menu 1 of menu bar item 1 of menu bar 2
		delay 0.5
		click menu item "LR-Home" of menu 1 of menu item 7 of menu 1 of menu bar item 1 of menu bar 2
	end tell
end tell

This got my drill-down to the second-level Stream Deck menu working.

1 Like

My usual solution for this is to use Type Ahead.

Click in the status menu to open the menu, then Insert Text by Typing “Stream Deck”, then Right Arrow, then Insert Text by Typing “Desired Profile Name”, then Return.

But I never have gotten the hang of mixing AppleScript and UI control.