在 C# 中使用自动化元素

Using AutomationElement in C#

我正在尝试在 C# 中使用 AutomationElement 对象进行 UIAutomation,但无法识别它。我猜它不是标准库的一部分,因为 Visual Studio 提示我说我可能缺少引用,但是我需要添加哪个引用才能使用 AutomationElement?

我试过 UIAutomationClient 但它没有用,尽管根据 Microsoft documentation.

这应该包含 AutomationElement

希望有人能帮忙

在您发布的 link 中您拥有所有信息,您需要添加对 UIAutomationClient 的引用(右键单击项目引用)并将命名空间 System.Windows.Automation 添加到您的源代码