Tim Nederveen
Tim Nederveen

Reputation: 135

Applescript not clicking menu item

I'm trying to add shortcuts to my Notes app for typing in superscript and subscript. The script below does not give any errors and correctly seems to find/click the 'Superscript' submenu item, but when returning to the notes app this option is not activated/selected. If I uncomment the line below it, that functionality (opening 'Notes Help') works perfectly.

tell application "System Events"
    tell process "Notes"
        click menu item "Superscript" of menu 1 of menu item "Baseline" of menu 1 of menu item "Font" of menu "Format" of menu bar 1
        -- click menu item "Notes Help" of menu "Help" of menu bar 1
    end tell
end tell

What am I doing wrong?

Upvotes: 0

Views: 723

Answers (1)

user2121361
user2121361

Reputation:

AppleScript code is usually all about personal style, but I just wrote this up real quick from probing the menubar. Tested and working properly.

tell application "Notes" to activate -- needed because you say "but when returning to the notes app" meaning you're not there already

-- tell System Events to Click, not tell system events to tell process to click... process doesn't understand click.

tell application "System Events"
    click menu item "Superscript" of menu "Baseline" of menu item "Baseline" of menu "Font" of menu item "Font" of menu "Format" of menu bar item "Format" of menu bar 1 of application process "Notes" of application "System Events"
end tell

Upvotes: 1

Related Questions