IUIAutomationElement::FindAll 方法 (uiautomationclient.h)

傳回滿足指定條件的所有 使用者介面自動化 專案。

語法

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

參數

scope

[in] condition

類型: IUIAutomationCondition*

條件的指標,表示要符合的準則。

[out, retval] found

類型: IUIAutomationElementArray**

接收相符項目的陣列指標。 如果找不到相符的專案,則傳回空陣列。

傳回值

類型: HRESULT

如果此方法成功,則會傳回 S_OK。 否則,它會傳回 HRESULT 錯誤碼。

備註

搜尋的範圍相對於呼叫 方法的專案。 元素會以樹狀結構中遇到的順序傳回。

此函式無法搜尋 Microsoft 使用者介面自動化 樹狀結構中的上階元素;也就是說,TreeScope_Ancestors不是範圍參數的有效值。

在桌面上搜尋最上層視窗時,請務必在 scope 參數中指定TreeScope_Children,而不是TreeScope_Descendants。 透過桌面整個子樹的搜尋可能會逐一查看數千個專案,並導致堆疊溢位。

如果您的用戶端應用程式可能會嘗試在自己的使用者介面中尋找元素,您必須在個別線程上發出所有 使用者介面自動化 呼叫。

規格需求

需求
最低支援的用戶端 Windows 7、Windows Vista SP2 和 Platform Update for Windows Vista、Windows XP 含 SP3 和適用於 Windows Vista 的平臺更新 [僅限傳統型應用程式]
最低支援的伺服器 Windows Server 2008 R2、Windows Server 2008 SP2 和 Platform Update for Windows Server 2008、Windows Server 2003 SP2 和 Platform Update for Windows Server 2008 [僅限桌面應用程式]
目標平台 Windows
標頭 uiautomationclient.h (包含 UIAutomation.h)

另請參閱

概念

FindAllBuildCache

FindFirst

FindFirstBuildCache

IUIAutomationElement

取得 UI 自動化項目

參考