private IUIAutomationElement GetParent(IUIAutomationTreeWalker treeWalker, IUIAutomationElement element)
        {
            if (element == null)
            {
                return(null);
            }

            return(treeWalker?.GetParentElement(element));
        }
예제 #2
0
        public AutomationElement GetParent()
        {
            IUIAutomationTreeWalker walker = factory.CreateTreeWalker();

            try {
                IUIAutomationElement elem;
                walker.GetParentElement(pElement, out elem);
                return((elem == null) ? null : new AutomationElement(elem, factory));
            }
            finally {
                if (walker != null)
                {
                    Marshal.ReleaseComObject(walker);
                }
            }
        }