There are often features only accessible via menus in-app and which have no direct command in the app's AppleScript dictionary. Happily the generic AppleScript System Events command allows 'remote control' operation of menus without needing to use extra utilities.
Below are a pair of AppleScripts sub-routines (akin to action code functions), one to press main menu items (e.g. File →Built-In Hints) and one to press sub-menu items (such as Format → Font → Bold). The examples should indicate how to extended the method to access more depley nested menus.
Top-level menus
This is for items in main menus like 'File', Note'. The sub-routing takes three arguments, all are required (see code comments for examples:
-- call example 1: my do_menu("Tinderbox 10", "Stamps", "Turn red")
-- call example 2: my do_menu("Tinderbox 10", "Edit", "Duplicate")
on do_menu(app_name, menu_name, menu_item)
try
tell application app_name to activate --must bring to front
tell application "System Events"
tell process app_name
tell menu bar 1
tell menu bar item menu_name
tell menu menu_name
click menu item menu_item
end tell
end tell
end tell
end tell
end tell
return true
on error error_message
return false
end try
end do_menu
Sub-menus
This is for items in sub-menus like 'File→Built-In Prototypes''. The sub-routing takes four arguments, all are required (see code comments for examples:
-- call example: my do_menu("Tinderbox 10", "Format", "Font", "Bold")
on do_menu(app_name, menu_name, menu_item, sub_item)
try
tell application app_name to activate --must bring to front
tell application "System Events"
tell process app_name
tell menu bar 1
tell menu bar item menu_name
tell menu menu_name
tell menu item menu_item
tell menu menu_item
click menu item sub_item
end tell
end tell
end tell
end tell
end tell
end tell
end tell
return true
on error error_message
return false
end try
end do_menu
More deeply nested menus
Adapt the last example above to nest extra menu(s). Each extra menu level will require an extra input argument (the name of the lowest level (most-nested) sub-menu.