AppleScript UI programming - how to Control-Click a UI element?

I’m doing some AppleScript UI programming, and there is a menu item that I need to access that only appears as a contextual menu when clicking in a particular UI element, i.e. it needs a control-click (or right-click, for people with right-hand mouse configuration) to appear, not just a standard click.


I can click the relevant UI element to select it OK in AppleScript:


tell application “System Events”
    tell application process [ target application ]
        click [ hierarchy to the relevant UI element ]
    end tell
end tell


But I need a control-click to make the menu appear. System Events cannot address the menu until after it appears.


How does one control-click in AppleScript? I searched the internet in vain, and I tried things like:


click [ hierarchy to the relevant UI element ] using control down


but that didn’t work - syntax error.


Surely control-clicking or right-clicking is a pretty basic function that can be done in AppleScript?


Thanks for any help.

Mac mini, macOS 14.6

Posted on Oct 5, 2024 1:33 AM

Reply

Similar questions

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AppleScript UI programming - how to Control-Click a UI element?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.