AutomationElement.RootElement 屬性

定義

取得目前桌面的根 AutomationElement

public:
 static property System::Windows::Automation::AutomationElement ^ RootElement { System::Windows::Automation::AutomationElement ^ get(); };
public static System.Windows.Automation.AutomationElement RootElement { get; }
static member RootElement : System.Windows.Automation.AutomationElement
Public Shared ReadOnly Property RootElement As AutomationElement

屬性值

根項目。

範例

下列範例程式碼會擷取桌面所有立即子系的集合。

AutomationElementCollection desktopChildren =
    AutomationElement.RootElement.FindAll(
    TreeScope.Children, Condition.TrueCondition);
Dim desktopChildren As AutomationElementCollection
desktopChildren = AutomationElement.RootElement.FindAll( _
    TreeScope.Children, Condition.TrueCondition)

備註

您可以使用 和 方法,使用根項目作為尋找其他元素 FindAllFindFirst 的起點。

從根項目搜尋時,請務必在搜尋範圍中指定 Children ,而不是 Descendants 。 透過桌面整個子樹的搜尋可能會逐一查看數千個專案,並導致堆疊溢位。

適用於