开发者

How do I inspect and activate other application’s menu?

Is it possible to inspect the main application menu of some already running application and execute开发者_Python百科 commands from this menu? For example retrieve the whole main menu hierarchy of Safari and execute the File → New Tab command (by its name, not using the keyboard shortcut). I’m interested in an Objective-C solution.


One way to do this is using the Cocoa Accessibility API

For example,

NSAccessibilityPickAction Selects the object, such as a menu item


You could use Applescript This is not exactly calling the menus but for a well written program provides the same functionality and using a defined and discoverable API.

To send the events see Scripting Bridge

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜