UI AppleScript Syntax Group A or Group B

Hi,

I’m hoping that there’s some way to write this so that it’s a single script.

This is working:

tell application "System Events"
	tell process "Logic Pro"
		get value of (every checkbox whose description is "bypass") of (every group whose value of attribute "AXDescription" does not contain "Loudness") of (first UI element whose value of attribute "AXDescription" contains "SUB MASTER") of UI element 2 of group 1 of (first window whose value of attribute "AXTitle" contains " - Mixer: All")
	end tell
end tell

But I’d like to search for 2 possible groups like this (this is not working with error:

"error "System Events got an error: Illegal comparison or logical." number -1726 from "automation" to record"):

tell application "System Events"
	tell process "Logic Pro"
		get value of (every checkbox whose description is "bypass") of (every group whose value of attribute "AXDescription" does not contain "Loudness" or "automation") of (first UI element whose value of attribute "AXDescription" contains "SUB MASTER") of UI element 2 of group 1 of (first window whose value of attribute "AXTitle" contains " - Mixer: All")
	end tell
end tell

– Groups with a description that do not contain either “Loudness” OR “automation” - can be either.

Is there a syntax that will work this way in AppleScript?

Thanks!

@unknownco

To get the elements you are looking for, you could use class of UI elements. I’m not a user of Logic Pro so it would be impossible for me to give more info.

When it comes to your approach, you like to do everything in 1 line of code. The problem is, how do you debug if you have problems. Only a missing round bracket could break your code when everything else is correct.

To debug your code you need to log where it breaks, and split it to more lines of code
before you think of 1 line of code as the solution.

1 Like

Hi @Fredrik71,

Thanks for the idea.

This is actually part of a larger macro with many other Apple and Bash scripts. With this particular script I was just hoping to avoid having to run it multiple times if I can grab all the particular UI Elements that meet these criteria at once. The result will only be a few elements, maybe 2-5 at the most. But AppleScript is slow and then add in the UI scripting and all the other random things I have to do to make sure it works (click an element twice with a delay so that it’s value correctly updates to true or false) and also that this is just one part of a larger macro with other AppleScript etc., so I’m just trying to be efficient.

I’ll look into the class of UI elements.

Thanks