来自 AXUIElement 的 CGWindowID [英] CGWindowID from AXUIElement

查看:14
本文介绍了来自 AXUIElement 的 CGWindowID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用可访问性 API 自动化外部 OSX 应用程序.一些应用程序的状态无法通过 API 获得,所以我通过屏幕抓取.为此,我需要为可访问性对象获取 CGWindowID窗口角色".

I'm trying to automate a foreign OSX application using the accessibility API. Some of the state of the application isn't available through the API, so I acquire it through screen scraping. To do this, I need to get CGWindowID for an accessibility object with a 'Window Role'.

是否有任何直接获取窗口角色"辅助功能对象的 CGWindowID 的方法?我可以通过匹配窗口的各种属性来启发式地获取它,例如大小,标题和位置,但这真的很hacky,如果我的我感觉更好应用程序也将支持极端情况,即使它们不太可能.

Is there any direct way of acquiring CGWindowID of a 'Window Role' accessibility object? I can get it heuristically, by matching various attributes of the window, such as the size, title and location, but this is really hacky, and I'd feel better if my application would also support the corner cases, even if they are unlikely.

推荐答案

没办法;可访问性层次结构与实际的窗口/视图层次结构完全分离.我认为您的匹配效果最好.

There’s no way to do that; the accessibility hierarchy is completely decoupled from the actual window/view hierarchy. I think your matching will work best.

这篇关于来自 AXUIElement 的 CGWindowID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆