简体   繁体   English

OS X:如何将上下文菜单单击从停靠图标转发到另一个应用程序?

[英]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... App A :目前不支持AppleScript的非开源Mac App Store应用程序App B :我自己的应用程序,可以用Objective-C,AppleScript,Python或其他任何方式编写。

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. 右键单击App A的停靠图标时,我会看到与该应用程序功能相关的自定义命令的上下文菜单选项。 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). 我想做的是用相同的命令填充App B的上下文菜单,当访问这些命令时,假定App A已打开(即使其停靠图标处于隐藏状态),将这些命令转发给AppA

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. 下载LiveCode 6.6.1 (我知道它的版本都可以使用)并向新的LiveCode文档添加按钮。 Select the button and press command-E to edit the script. 选择按钮,然后按Command-E编辑脚本。 Enter the following synax (for testing): 输入以下synax(用于测试):

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. 这很有用,因为您还可以将AppleScript和GUI脚本与LiveCode一起使用。 Let LiveCode be app B and have it control app A. 让LiveCode成为应用B,并让它控制应用A。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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