无法从模式窗口获取所有子元素

时间:2019-07-10 13:02:39

标签: c# ui-automation

我正在尝试访问模式窗口中存在的复选框。 然后使用UI-automation / uiacomwrapper取消选中它。

我能够做到,但是在某些应用程序中,它失败了。 例如,说团队查看器。我无法访问模式窗口中的复选框。

var testi = win.GetWindowByName("TeamViewer");
        var child_win = win.GetChildWindow();
        var window = (AutomationElement)child_win.Element;

        var cb = window.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Start TeamViewer with Windows"));

它应该在cb中返回一些值,但是它返回null。 相同的代码在其他Windows窗体和WPF应用程序中运行良好。 仅在使用Team Viewer的情况下,它返回null。enter image description here

1 个答案:

答案 0 :(得分:0)

由于我不使用Team Viewer,因此我在这里不确定100%。

NameProperty将查找其Name与您的输入匹配的元素。通常,名称对于程序员来说是有意义的。您可能需要遍历元素并选择其标题与查询匹配的元素。