0

Question: Is there any way for one app to programmatically access and activate the contextual menu items that can be accessed when right clicking on the dock icon of another application?

App A: Non-open source Mac App Store app that currently has no AppleScript support App B: My own application, which I could write in Objective-C, AppleScript, Python, whatever...

When I right click on the dock icon for App A, I see contextual menu options for custom commands related to the function of that application. What I would like to do is to populate the contextual menu for App B with the same commands, which when accessed forward those commands to App A assuming that App A is open (even if its dock icon is hidden).

Is this sort of thing possible?

Maia
  • 1
  • The thing is, App A's menu can be dynamic. It may not even be populated until it's shown. The means by which the Dock prompts it to populate that menu and convey its contents to the Dock is private to Apple. You can use the Accessibility API to drive the Dock to open App A's menu and then read its contents, but that doesn't sound like what you're really after. – Ken Thomases Jun 01 '14 at 21:47
  • Hi Ken, thanks for the feedback. I have seen solutions like those in questions like: http://stackoverflow.com/questions/2819807/accessing-dock-icon-right-click-menu-items-with-applescript?rq=1 . But you're right; I would prefer a solution that doesn't involve triggering any UI elements in the process. – Maia Jun 01 '14 at 22:04

1 Answers1

0

Here's an idea. Download LiveCode 6.6.1 (the version of which I know that it all works) and add a button to a new LiveCode document. Select the button and press command-E to edit the script. Enter the following synax (for testing):

on mouseUp
  put "test" & cr & tab & "test1" into myMenu
  set the iconMenu to myMenu
end mouseUp

on iconMenuPick theItem
  if theItem contains "test1" then
    answer "You chose" && theItem
  end if
end iconMenuPick

This is useful, because you can also use AppleScript and GUI scripting with LiveCode. Let LiveCode be app B and have it control app A.

Mark
  • 2,380
  • 11
  • 29
  • 49