CefSharp 窗口的 UI 自动化不可能

发布于 2025-01-09 05:26:30 字数 626 浏览 6 评论 0原文

我正在尝试使 CefSharp 窗口可以通过 MS UI 自动化工具(例如spectr.exe 或 UISpy)进行访问。 默认情况下,CefSharp 窗口被视为图像,并且 UI 属性不可访问。

我已经设置了命令行参数“force-renderer-accessibility”。它本身没有改变任何东西,但后来我添加了这段代码:

browser.AccessibilityHandler = new AccessibilityHandler(browser);
browser.IsBrowserInitializedChanged += (sender, args) =>
{
    if ((bool)args.NewValue)
    {
        browser.GetBrowserHost().SetAccessibilityState(CefState.Enabled);
    }
};

它部分起作用,我可以访问大多数控件,但其中一些控件仍然无法访问(它们被 UISpy 称为“组”,你不能作为树节点更深入地遍历它们)。扫描还发现一些物品偏离其真实位置。

有没有更好的方法让 CefSharp WPF 窗口可供 UI 自动化工具使用?我做错了什么吗?

我正在使用 CefSharp 97.1.12

I'm trying to make CefSharp window accessible with MS UI Automation tools like inspect.exe or UISpy.
By default the CefSharp windows is treated by these as an image and the UI properties are inaccessible.

I've set the commandline argument "force-renderer-accessibility". Itself it didn't change anything, but then I added this code:

browser.AccessibilityHandler = new AccessibilityHandler(browser);
browser.IsBrowserInitializedChanged += (sender, args) =>
{
    if ((bool)args.NewValue)
    {
        browser.GetBrowserHost().SetAccessibilityState(CefState.Enabled);
    }
};

It partially worked, I can access most of the controls, but some of them are still inaccessible (they are referred to by UISpy as 'group' and you can't traverse them deeper as tree nodes). Also the scan finds some items a bit away from their real position.

Is there a better way to make CefSharp WPF window available to UI automation tools? Is there something I'm doing wrong?

I'm using CefSharp 97.1.12

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文