TreeWalker.GetNextSibling Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar nästa syskonelement i det angivna AutomationElement.
Överlagringar
| Name | Description |
|---|---|
| GetNextSibling(AutomationElement, CacheRequest) |
Hämtar nästa syskonelement i de angivna AutomationElement egenskaperna och cachelagrar egenskaper och mönster. |
| GetNextSibling(AutomationElement) |
Hämtar nästa syskonelement i det angivna AutomationElement. |
Kommentarer
En AutomationElement kan ha ytterligare syskonelement som inte matchar det aktuella vyvillkoret och därför inte returneras när du navigerar i elementträdet.
Strukturen för AutomationElement trädet ändras när de synliga användargränssnittselementen (UI) på skrivbordet ändras. Det är inte garanterat att ett element som returneras som nästa syskonelement returneras som nästa syskon vid efterföljande pass.
GetNextSibling(AutomationElement, CacheRequest)
Hämtar nästa syskonelement i de angivna AutomationElement egenskaperna och cachelagrar egenskaper och mönster.
public:
System::Windows::Automation::AutomationElement ^ GetNextSibling(System::Windows::Automation::AutomationElement ^ element, System::Windows::Automation::CacheRequest ^ request);
public System.Windows.Automation.AutomationElement GetNextSibling(System.Windows.Automation.AutomationElement element, System.Windows.Automation.CacheRequest request);
member this.GetNextSibling : System.Windows.Automation.AutomationElement * System.Windows.Automation.CacheRequest -> System.Windows.Automation.AutomationElement
Public Function GetNextSibling (element As AutomationElement, request As CacheRequest) As AutomationElement
Parametrar
- element
- AutomationElement
Elementet som du vill hämta nästa syskon från.
- request
- CacheRequest
Ett cachebegärandeobjekt som anger egenskaper och mönster för den som returneras till cacheminnet AutomationElement .
Returer
Nästa syskonelement eller en null-referens (Nothing i Visual Basic) om det inte finns något sådant element.
Kommentarer
En AutomationElement kan ha ytterligare syskonelement som inte matchar det aktuella vyvillkoret och därför inte returneras när du navigerar i elementträdet.
Strukturen för AutomationElement trädet ändras när de synliga användargränssnittselementen (UI) på skrivbordet ändras. Det är inte garanterat att ett element som returneras som nästa syskonelement returneras som nästa syskon vid efterföljande pass.
Se även
- Översikt över automationsträd för användargränssnittet
- Navigera bland UI Automation-element med TreeWalker
- Obtaining UI Automation Elements
Gäller för
GetNextSibling(AutomationElement)
Hämtar nästa syskonelement i det angivna AutomationElement.
public:
System::Windows::Automation::AutomationElement ^ GetNextSibling(System::Windows::Automation::AutomationElement ^ element);
public System.Windows.Automation.AutomationElement GetNextSibling(System.Windows.Automation.AutomationElement element);
member this.GetNextSibling : System.Windows.Automation.AutomationElement -> System.Windows.Automation.AutomationElement
Public Function GetNextSibling (element As AutomationElement) As AutomationElement
Parametrar
- element
- AutomationElement
Från AutomationElement vilken du kan hämta nästa syskon.
Returer
Nästa syskonelement eller en null-referens (Nothing i Visual Basic) om det inte finns något sådant element.
Exempel
I följande exempel visas GetNextSibling hur du skapar en trädvy över element i ett underträd.
/// <summary>
/// Walks the UI Automation tree and adds the control type of each element it finds
/// in the control view to a TreeView.
/// </summary>
/// <param name="rootElement">The root of the search on this iteration.</param>
/// <param name="treeNode">The node in the TreeView for this iteration.</param>
/// <remarks>
/// This is a recursive function that maps out the structure of the subtree beginning at the
/// UI Automation element passed in as rootElement on the first call. This could be, for example,
/// an application window.
/// CAUTION: Do not pass in AutomationElement.RootElement. Attempting to map out the entire subtree of
/// the desktop could take a very long time and even lead to a stack overflow.
/// </remarks>
private void WalkControlElements(AutomationElement rootElement, TreeNode treeNode)
{
// Conditions for the basic views of the subtree (content, control, and raw)
// are available as fields of TreeWalker, and one of these is used in the
// following code.
AutomationElement elementNode = TreeWalker.ControlViewWalker.GetFirstChild(rootElement);
while (elementNode != null)
{
TreeNode childTreeNode = treeNode.Nodes.Add(elementNode.Current.ControlType.LocalizedControlType);
WalkControlElements(elementNode, childTreeNode);
elementNode = TreeWalker.ControlViewWalker.GetNextSibling(elementNode);
}
}
''' <summary>
''' Walks the UI Automation tree and adds the control type of each element it finds
''' in the control view to a TreeView.
''' </summary>
''' <param name="rootElement">The root of the search on this iteration.</param>
''' <param name="treeNode">The node in the TreeView for this iteration.</param>
''' <remarks>
''' This is a recursive function that maps out the structure of the subtree beginning at the
''' UI Automation element passed in as rootElement on the first call. This could be, for example,
''' an application window.
''' CAUTION: Do not pass in AutomationElement.RootElement. Attempting to map out the entire subtree of
''' the desktop could take a very long time and even lead to a stack overflow.
''' </remarks>
Private Sub WalkControlElements(ByVal rootElement As AutomationElement, ByVal treeNode As TreeNode)
' Conditions for the basic views of the subtree (content, control, and raw)
' are available as fields of TreeWalker, and one of these is used in the
' following code.
Dim elementNode As AutomationElement = TreeWalker.ControlViewWalker.GetFirstChild(rootElement)
While (elementNode IsNot Nothing)
Dim childTreeNode As TreeNode = treeNode.Nodes.Add(elementNode.Current.ControlType.LocalizedControlType)
WalkControlElements(elementNode, childTreeNode)
elementNode = TreeWalker.ControlViewWalker.GetNextSibling(elementNode)
End While
End Sub
Kommentarer
En AutomationElement kan ha ytterligare syskonelement som inte matchar det aktuella vyvillkoret och därför inte returneras när du navigerar i elementträdet.
Strukturen för AutomationElement trädet ändras när de synliga användargränssnittselementen (UI) på skrivbordet ändras. Det är inte garanterat att ett element som returneras som nästa syskonelement returneras som nästa syskon vid efterföljande pass.
Se även
- Översikt över automationsträd för användargränssnittet
- Navigera bland UI Automation-element med TreeWalker
- Obtaining UI Automation Elements