Understanding AppleScript UI-Scripting to Click Menus

There is a bug with the click command. It’ll work immediately the first time round which is fine if you’re just toggling a button like low latency mode

Ie


Tell application “System Events” to tell process “Logic Pro”
       Set tracks_window to title of first window whose title contains “_Tracks”
       set front most to true
       Tell checkbox “Low Latency Monitoring Mode” of group 1 of window tracks_window
             Click
        End tell
End tell

But if you need to send more events after the click, I would download a command line program called cliclick (command line interface click)

Then, find the ui element, note that the ui element can change depending on the window layout in logic. so if you can find the accessibility description rather than entering button 2 you could say

Here’s an example using cliclick

`Tell application “System Events” to tell process “Logic Pro”
       Set tracks_window to title of first window whose title contains “_Tracks”
       set front most to true 
Set theImage to (The first button of UI element 1 of group 2 of list 1 of window tracks_window whose accessibility description = “xxx”
Set {x, y} to position of theImage
Do shell script “/user/local/Cellar/cliclick/5.x/bin/cliclick dc:” & x & “,” & y `

After that, in the same tell block, you can use keystrokes and key codes to navigate through a pop up menu. With accessibility descriptions you can do a lot with gui scripting in Logic Pro. Here’s some examples from apple scripts I’ve worked into better touch tool