小编rca*_*bbi的帖子

如何访问 UI Spy 看不到的元素以使用 C# 自动化 win32 应用程序

我正在做一个 C# windows 窗体应用程序,它使用 System.Windows.Automation 类自动化另一个 win32 应用程序。

有一些元素我需要阅读或交互,但 UISpy 没有找到这些字段,它只找到了父容器面板。

例如,下面的代码块应该返回许多工具条按钮但不起作用:

var mainWindow = AutomationElement.RootElement.FindChildByNamePart("Back Office Control");
var mainWindowChildren = mainWindow.FindAll(TreeScope.Children, Condition.TrueCondition);
var toolBarPanel = mainWindowChildren[1];
var toolBarItens = toolBarPanel.FindAll(TreeScope.Children, Condition.TrueCondition);
Run Code Online (Sandbox Code Playgroud)

还有另一种方法可以做到这一点吗?

.net c# ui-automation winforms ui-spy

5
推荐指数
1
解决办法
2628
查看次数

标签 统计

.net ×1

c# ×1

ui-automation ×1

ui-spy ×1

winforms ×1