AppleScript to launch a menu bar command

I’m trying to automate my workflow with Apple Shortcuts to launch the grammar corrector I use for Word documents called Antidote. That corrector integrates with Word and other software via a companion app called Connectix, and it can be launched either by clicking a button on a floating menu or through the menu bar (see screenshots below). It has to be launched with a Word document as the frontmost document. Is that possible to achieve with AppleScript?


@80sTherapy. I don’t know of a good way to do what you want. An approach that works in my testing–but is a bit kludgey–is to use System Events’ click command. For example, the following script clicks on the sound icon in my menu bar and then clicks on the “Sound Settings” menu item. It does work reliably on my Ventura computer as long as I don’t change the menu bar.

tell application "System Events"
	click at {1715, 10}
	delay 0.5 -- test different values
	click at {1500, 210}
end tell

The following script helps to get the cursor coordinates. To use this, open in a script editor, move the cursor to the desired location, and run the script using keyboard shortcuts.

use framework "AppKit"
use framework "Foundation"
use scripting additions

set cursorPosition to current application's NSEvent's mouseLocation()
set {{x1, y1}, {x2, y2}} to (current application's NSScreen's mainScreen())'s frame()
set {c1, c2} to {(cursorPosition's x as integer), (y2 as integer) - (cursorPosition's y as integer)}
display dialog "The x offset is " & c1 & linefeed & "The y offset is " & c2 with title "Global Cursor Coordinates"
set the clipboard to (c1 as text) & space & c2

BTW, I’m not familiar with Shortcuts app, but I assume it has the ability to run a script by way of a keyboard shortcut, the same as Automator. Another option is to run the script by way of an app like FastScripts.