TreeWalker.GetNextSibling メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した AutomationElementの次の兄弟要素を取得します。
オーバーロード
| Name | 説明 |
|---|---|
| GetNextSibling(AutomationElement, CacheRequest) |
指定した AutomationElement の次の兄弟要素を取得し、プロパティとパターンをキャッシュします。 |
| GetNextSibling(AutomationElement) |
指定した AutomationElementの次の兄弟要素を取得します。 |
注釈
AutomationElementには、現在のビュー条件と一致しないため、要素ツリー内を移動するときに返されない追加の兄弟要素を含めることができます。
デスクトップ上の表示されるユーザー インターフェイス (UI) 要素が変更されると、 AutomationElement ツリーの構造が変わります。 次の兄弟要素として返された要素が、後続のパスで次の兄弟として返されることは保証されません。
GetNextSibling(AutomationElement, CacheRequest)
指定した AutomationElement の次の兄弟要素を取得し、プロパティとパターンをキャッシュします。
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
パラメーター
- element
- AutomationElement
次の兄弟を取得する要素。
- request
- CacheRequest
キャッシュに返される AutomationElement のプロパティとパターンを指定するキャッシュ要求オブジェクト。
戻り値
このような要素がない場合は、次の兄弟要素、または null 参照 (Visual Basic では Nothing)。
注釈
AutomationElementには、現在のビュー条件と一致しないため、要素ツリー内を移動するときに返されない追加の兄弟要素を含めることができます。
デスクトップ上の表示されるユーザー インターフェイス (UI) 要素が変更されると、 AutomationElement ツリーの構造が変わります。 次の兄弟要素として返された要素が、後続のパスで次の兄弟として返されることは保証されません。
関連項目
適用対象
GetNextSibling(AutomationElement)
指定した 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
パラメーター
- element
- AutomationElement
次の兄弟を取得する AutomationElement 。
戻り値
このような要素がない場合は、次の兄弟要素、または null 参照 (Visual Basic では Nothing)。
例
次の例 GetNextSibling 、サブツリー内の要素のツリー ビューを構築するために使用されています。
/// <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
注釈
AutomationElementには、現在のビュー条件と一致しないため、要素ツリー内を移動するときに返されない追加の兄弟要素を含めることができます。
デスクトップ上の表示されるユーザー インターフェイス (UI) 要素が変更されると、 AutomationElement ツリーの構造が変わります。 次の兄弟要素として返された要素が、後続のパスで次の兄弟として返されることは保証されません。