コード例 #1
0
        private void EnumarateChildren(IUIAutomationElement element)
        {
            Console.WriteLine("{0}", element.CurrentName.Trim());


            IUIAutomationCacheRequest cacheRequest = _automation.CreateCacheRequest();

            cacheRequest.AddProperty(System.Windows.Automation.AutomationElement.NameProperty.Id);
            cacheRequest.AddProperty(System.Windows.Automation.AutomationElement.ControlTypeProperty.Id);
            cacheRequest.TreeScope = TreeScope.TreeScope_Element | TreeScope.TreeScope_Children | TreeScope.TreeScope_Subtree;

            IUIAutomationCondition cond;

            cond = _automation.CreatePropertyConditionEx(
                System.Windows.Automation.AutomationElement.ControlTypeProperty.Id,
                System.Windows.Automation.ControlType.Window.Id,
                PropertyConditionFlags.PropertyConditionFlags_IgnoreCase);

            IUIAutomationElementArray elementList = element.FindAllBuildCache(TreeScope.TreeScope_Children, cond, cacheRequest);

            if (elementList == null)
            {
                return;
            }

            for (int i = 0; i < elementList.Length; i++)
            {
                EnumarateChildren(elementList.GetElement(i));
            }
        }
コード例 #2
0
        /// <summary>
        /// Build a cacherequest for properties and patterns
        /// </summary>
        /// <param name="uia"></param>
        /// <param name="pps">Property ids</param>
        /// <param name="pts">Pattern ids</param>
        /// <returns></returns>
        public static IUIAutomationCacheRequest GetPropertiesCache(CUIAutomation uia, List <int> pps, List <int> pts)
        {
            if (uia == null)
            {
                throw new ArgumentNullException(nameof(uia));
            }

            var cr = uia.CreateCacheRequest();

            if (pps != null)
            {
                foreach (var pp in pps)
                {
                    cr.AddProperty(pp);
                }
            }

            if (pts != null)
            {
                foreach (var pt in pts)
                {
                    if (pt != 0)
                    {
                        cr.AddPattern(pt);
                    }
                }
            }

            return(cr);
        }
コード例 #3
0
        /// <summary>
        /// Build a cacherequest for properties and patterns
        /// </summary>
        /// <param name="uia"></param>
        /// <param name="pps">Property ids</param>
        /// <param name="pts">Pattern ids</param>
        /// <returns></returns>
        public static IUIAutomationCacheRequest GetPropertiesCache(CUIAutomation uia, List <int> pps, List <int> pts)
        {
            var cr = uia.CreateCacheRequest();

            if (pps != null)
            {
                foreach (var pp in pps)
                {
                    cr.AddProperty(pp);
                }
            }

            if (pts != null)
            {
                foreach (var pt in pts)
                {
                    if (pt != 0)
                    {
                        cr.AddPattern(pt);
                    }
                }
            }

            return(cr);
        }
コード例 #4
0
ファイル: Helpers.cs プロジェクト: peterdur/axe-windows
        private static IUIAutomationElement GetDesktopElement()
        {
            IUIAutomation uia = new CUIAutomation();

            var cacheRequest = uia.CreateCacheRequest();

            cacheRequest.AddProperty(PropertyType.UIA_BoundingRectanglePropertyId);

            return(uia.GetRootElementBuildCache(cacheRequest));
        }