如何访问所有菜单栏图标
我说的是菜单栏右侧显示的图标。 访问该菜单栏
我可以使用 (py-appscript) app(u'System Events').processes[u'SystemUIServer'].menu_bars[1]
& menu_bar_item[1], menu_bar_items[1] &依此类推,请参阅每个图标。
但是,有几个图标无法使用此方法引用。例如,角落里的搜索图标不属于SystemUIServer。同样,我们的应用程序的图标也显示在那里,但不能像上面的示例一样被引用。那么我如何引用这些图标呢?我想执行单击、右键单击等操作。有没有办法列出栏上显示的所有图标?这样我就可以随时抢到位置并获得胜利。那样点击它们。有什么建议吗?
I'm talking about the icons that show up on the right hand side of the menu bar. I can get access to that menu bar with (py-appscript)
app(u'System Events').processes[u'SystemUIServer'].menu_bars[1]
& menu_bar_item[1], menu_bar_items[1] & so on refer to each of the icons.
But, there are couple of icons up there that cannot be referenced using this method. For e.g. the search icon in the corner doesn't belong to SystemUIServer. Similarly, our app's icon also shows up there but cannot be referenced like the above example. So how can I reference those icons? I want to perform actions like click, right-click etc. IS there any way to list all the icons displayed on the bar? That way I can always grab the position & click them that way. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编写聚光灯菜单脚本的最简单方法是通过 GUI 脚本发送按键。我认为它不能以您想要的方式访问。至于为什么你的图标不会列出,我不确定。它有与之相关的菜单吗?
列出所有菜单很容易。这是一个用于执行此操作的 Python 脚本。然后,您可以使用该数据通过 Appscript 直接访问它们。
http://www.libertypages.com/clarktech/?p=2193
Easiest way to script the spotlight menu is to just send the keys via GUI scripting. I don't think it can be accessed in the fashion you want. As for why your icon won't list I'm not sure. Does it have a menu associated with it?
It's easy to list all the menulings. Here's a Python script to do so. You can then use that data to access them directly with Appscript.
http://www.libertypages.com/clarktech/?p=2193