I can't see how it could be a macOS issue. I think the script just needs tweaking somehow.
Try running that test macro again. Once you have the script displayed in its prompt, switch profile on your SD away from the one the script points to, then press "Test" in the prompt. Does the SD switch profile?
Not sure either, the only way I got it to work was by using menu item numbers.
So that's the best option for me at the moment, thank you again!
activate application "Elgato Stream Deck"
tell application "System Events"
tell process "Stream Deck"
click menu item 5 of menu 1 of menu bar item 1 of menu bar 2
end tell
end tell
That "1" in menu bar item "1" shouldn't be quoted -- that's what's throwing this error. The quotes effectively mean "the menu bar item with this name" but there is no menu bar item named "1".
You should be able to do:
activate application "Elgato Stream Deck"
tell application "System Events"
tell process "Stream Deck"
click menu item "Resolve Edit" of menu 1 of menu bar item 1 of menu bar 2
end tell
end tell
...to target the "Resolve Edit" profile, changing the text to match the name for your other profiles. That will make your script more robust, since you aren't relying on the item's position in the menu.
@noisneil's macro just reveals the item's position in the UI hierarchy. To follow along in your own UI you work backwards:
menu bar 2 is the "Stream Deck" process's second menu bar, the one where you can see the SD menu item on your screen
menu bar item 1 is the SD icon itself
menu 1 is the menu that pops when you click the SD icon
menu item 5 is the 5th item in that menu
That's for when you have only one SD connected. When you have more than one each SD gets its own menu item in menu 1 (menu item "Stream Deck XL" in @noisneil's example) which has its menu (menu "Stream Deck XL") containing menu items (menu item "Keyboard Maestro").
And yes, it all gets a bit confusing when it's written the opposite way to how you think of it... Which is why it can be easier to use "nested tells" rather than "...of...of...":
activate application "Elgato Stream Deck"
tell application "System Events"
tell process "Stream Deck"
tell menu bar 2
tell menu bar item 1
tell menu 1
tell menu item 5
click
end tell
end tell
end tell
end tell
end tell
end tell
Perhaps easier to understand when reading, but the verbosity makes it much harder to edit.
Thank you for your explanation! But even when I have multiple SD connected I can't use the menu item name to target a specific SD, like "Stream Deck XL" for example.
It might be different OS or SD software versions, but when it comes to "System Events" and UI scripting there are so many potential variables that you're often left to poking around yourself. For example, you say that click menu item 5... works for you -- for me that item is a divider so clicking it has no effect.
Launch the Script Editor app (in Applications -> Utilities), paste in
tell application "System Events"
tell process "Stream Deck"
name of every menu item of menu 1 of menu bar item 1 of menu bar 2
end tell
end tell
...and select "Run" from the "Script" menu. What appears in the "Result" pane at the bottom of the window?
And since you're only listing a single level of menu items you can see that, while @noisneil appears to have a sub-menu for each SD, your menu is "flat" and includes an SD name, the profiles for that SD, and separated from the next SDs by a divider (missing value).
Compare that with mine: {"Configure Stream Deck", missing value, "Close Window", "Minimize Window", missing value, "Stream Deck", "Default Profile", "Teams", "Test", missing value, "Preferencesā¦", "Elgato Marketplaceā¦", missing value, "Quit Stream Deck"} where you'll see I've extra "Close Window", "Minimize Window" and missing value items -- which is why your item 5 is my item 8...
Which shows the value of poking around in your own menus.
The main practical effect of the differences is that you'll have to be careful if two SDs have profiles with the same name -- @noisneil can specifically target the correct one by name and path, but you'll have to do a bit more work.
Yes it's up to date, even upgraded to the beta to see if that changes anything. But I'm still on macOS Sonoma, I'm pretty sure that's the reason. I researched and found some images with the SD submenus like you have and they all seemed to be on a newer OS. Thanks again @noisneil and @Nige_S !!
Thank you! I've now implemented this approach throughout my 14 Photoshop profiles. I can definitely work with this.
One more idea (This may be a bridge too far!):
While this allows me to switch from profile A to profile B and back to profile A, if I go from profile B to profile C, Stream Deck canāt find its way back to A.
Would it be possible to switch through a chain of two profiles, then retrace the route?