Applescript/JXA/System Events - Search UI Elements?

So this had actually started as a ‘how do I list all UI elements’ question - but then the ‘similar topics’ popup led me to UI Browser, which is excellent. But I’m a little unclear on some things - first step I’ll end up needing is to be able to search the top level windows of a program for one that has a title that includes/starts with the word “Edit:” and then be able to target that window (by an ID maybe?) later on. Any hints on that would be appreciated! I was using this script:

tell application "System Events"
tell application process "Pro Tools"
	
	{¬
		windows, ¬
		null}
	
end tell
end tell

to show me just the names of windows, but man the result is ugly (lots of fluff!) – is there any better way than just parsing through that fluffy string?

You can try:
set oWin to first window whose title contains "edit"

Here's an example script I did using Evernote, since I don't have Pro Tools:

set AppleScript's text item delimiters to linefeed

tell application "System Events"
  tell application process "Evernote"
    set winList to every window
    set {winTitleList, winIDList} to {title, id} of every window
    
    log ("winTitles: ") & winTitleList
    set oWin to first window whose title contains "Evernote"
    properties of oWin
  end tell
end tell

Make sure you have the log panel at the bottom of Script Editor enabled.
Click on this button to enable:

You should see something like this:

Hopefully that will give you some clues.