开发者

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

开发者 https://www.devze.com 2023-02-06 09:57 出处:网络
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 Safa

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

精彩评论

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