简体   繁体   中英

OS X: How can I forward contextual menu clicks from dock icon to another application?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM