IUIAutomationElement::FindAll 方法 (uiautomationclient.h)

返回满足指定条件的所有UI 自动化元素。

语法

HRESULT FindAll(
                TreeScope                 scope,
  [in]          IUIAutomationCondition    *condition,
  [out, retval] IUIAutomationElementArray **found
);

参数

scope

[in] condition

类型: IUIAutomationCondition*

指向表示要匹配的条件的条件的指针。

[out, retval] found

类型: IUIAutomationElementArray**

接收指向匹配元素数组的指针。 如果未找到匹配的元素,则返回空数组。

返回值

类型: HRESULT

如果该方法成功,则返回 S_OK。 否则,将返回 HRESULT 错误代码。

注解

搜索范围相对于调用方法的元素。 元素按它们在树中遇到的顺序返回。

此函数无法搜索 Microsoft UI 自动化 树中的上级元素;也就是说,TreeScope_Ancestors 不是范围参数的有效值。

在桌面上搜索顶级窗口时,请确保在 scope 参数中指定TreeScope_Children,而不是TreeScope_Descendants。 在桌面的整个子树中搜索可能会循环访问数千个项目,并导致堆栈溢出。

如果客户端应用程序可能尝试在其自己的用户界面中查找元素,则必须在单独的线程上进行所有UI 自动化调用。

要求

要求
最低受支持的客户端 Windows 7、带 SP2 的 Windows Vista 和适用于 Windows Vista 的平台更新、带 SP3 的 Windows XP 和适用于 Windows Vista 的平台更新 [仅限桌面应用]
最低受支持的服务器 Windows Server 2008 R2、带 SP2 的 Windows Server 2008 和适用于 Windows Server 2008 的平台更新、带 SP2 的 Windows Server 2003 和适用于 Windows Server 2008 的平台更新 [仅限桌面应用]
目标平台 Windows
标头 uiautomationclient.h (包括 UIAutomation.h)

请参阅

概念性

FindAllBuildCache

FindFirst

FindFirstBuildCache

IUIAutomationElement

获取 UI 自动化元素

引用