Searching Pop Up Menus in Pro Tools via Applescript?

Hey folks, having a bit of a head-scratcher here. I’m trying to script some stuff in Avid Pro Tools, and I need to get at a menu triggered by a pop up button.

UI Browser is confusing me a bit (the hierarchy to elements in the menu when using the screen reader is:

ELEMENT PATH (starting at leaf element): ((/not sure what this means/))
   menu item "User Time Stamp"  (menu item 6)
      menu (menu 1)
         menu item "Sort by"  (menu item 7)
            menu (menu -9223372036854775808
               [MISMATCH-different children]   application "Pro Tools"

Ideally, I’d need to be able to search one of these types of menus, as the items in them change a lot (I’ll be defining one of the menu items I’m looking for elsewhere in the script, through another part of Pro Tools).

Annoyingly the menus disappear if I try and do much of anything in UI Browser after opening them, so I’m not sure where to start. From what I can tell, they don’t seem to actually be contained within the Pro Tools process’ hierarchy.

Any thoughts?

The rest of my script currently looks like this (which is contained in a MASSIVE macro at the moment):

tell application "System Events" 
	set EditWindow to a reference to (every window of process "Pro Tools" whose name contains "Edit")
	set Aux1 to a reference to (every group of EditWindow whose name contains "Aux 1")
	set Aux1Name to a reference to pop up button 1 of Aux1
	click pop up button 1 of Aux1
end tell

It’s a bit more verbose than one would expect because I’m hoping to use this as a sort of framework for some other functions.

Dynamic menus can be a nightmare to script, as you are finding out.
Sorry I don’t have a specific solution for you (I don’t have the Avid Pro Tools app), but you may want to do a google search something like this:
AppleScript Avid Pro Tools

I found this one that looks really promising:
Automation AppleScripts for Pro Tools (Mac)

Good luck and let us know if you find something helpful.

Hi JM - yeah sadly I think I’m doing some things nobody else with Pro Tools has even bothered to attempt, so I’m a bit in the wilderness with it. There’s a lot of things I have ideas for, I just have to slam my head against the wall a bit until I’m comfortable with applescript again (been a few years/decades).

OK @mushoo, I get your point. It still may be worth a post or two to the Avid group. You might be surprised.

If you’re not getting anywhere, you might also try posting to these AppleScript forums/lists:

  1. Applescript-users list (ASUL)
  2. MacScripter.net

@mushoo, how did you get on with this? I am a noob with applscripts but am slowly getting into scripting for Pro Tools and would love to be able to control things like telling the script to wait until the processing pop-up window has closed before continuing etc.
Cheers!

There's a couple things you can do, IIRC (not at the machine I usually do this stuff on, what with the quarantine and all).

One is to wrap the open-menu command in an 'ignoring application responses' and 'end ignoring' phrase (which seems to only sometimes work, and then sometimes you ALSO have to force restart the system events process?)

The other is to use (ugh) mouse clicks - I generally use applescript to get the screen position of the thing I want to click, then pass that along to KM to have it do the clicking. Once the menu is open, have KM 'type' the first few letters (you can use the 'use variable' action, I think) of the item you want to select, and then hit enter/return.

Which is fine for actually selecting pop-up menu items, but doesn't help AT ALL if you need to check if a popup menu item is enabled/disabled, though.

Hey, sorry for the slow reply, Thanks for responding. Yeah I started out with mouse clicks but am seeing how far I can delve into scripting. As you mentioned through I think it has to be a combo of scripting and then mouse clicks because of things like plugin windows being hidden / not at the forefront. So I'll keep digging and playing to see how far I can go! Many thanks!