UIAutomationWrapper.AutomationWrapper.GetAncestorWithHandle C# (CSharp) Méthode

GetAncestorWithHandle() private méthode

private GetAncestorWithHandle ( AutomationElement element ) : AutomationElement
element System.Windows.Automation.AutomationElement
Résultat System.Windows.Automation.AutomationElement
        private AutomationElement GetAncestorWithHandle(AutomationElement element)
        {
            try
            {
                var walker = new TreeWalker(Condition.TrueCondition);
                var testParent = walker.GetParent(element);

                while (testParent != null && testParent.Current.NativeWindowHandle == 0)
                {
                    testParent = walker.GetParent(testParent);

                    if (
                        testParent != null &&
                        testParent.Current.ProcessId > 0 &&
                        testParent.Current.NativeWindowHandle != 0
                    )
                        return testParent;
                }

                return
                    testParent.Current.NativeWindowHandle != 0
                    ? testParent
                    : null;
            }
            catch
            {
                return null;
            }
        }