Example #1
0
        public AutomationTreeElementWrapper GetRootInit()
        {
            Queue <AutomationElement> aeQueue = new Queue <AutomationElement>();
            Condition conditions = Condition.TrueCondition;

            AutomationElement            root        = AutomationElement.RootElement;
            AutomationTreeElementWrapper rootWrapper = new AutomationTreeElementWrapper(root);
            AutomationElementCollection  aec         = root.FindAll(TreeScope.Children, conditions);

            foreach (AutomationElement ae in aec)
            {
                rootWrapper.AddChild(new AutomationTreeElementWrapper(ae));
            }
            #region get from process list
            /// get from process list
            ///

            /*
             * Process[] allProcesses = Process.GetProcesses();
             * foreach(Process proc in allProcesses)
             * {
             *  Condition tempCondition = new PropertyCondition(AutomationElement.ProcessIdProperty, proc.Id);
             *  AutomationElement ae = AutomationElement.RootElement.FindFirst(TreeScope.Element | TreeScope.Children, tempCondition);
             *  if (ae != null)
             *      aeQueue.Enqueue(ae);
             * }
             */
            #endregion
            return(rootWrapper);
        }
Example #2
0
        public void MakeTree()
        {
            AutomationTreeElementWrapper rootWrapper = GetRootInit();

            TreeWalker walker = TreeWalker.RawViewWalker;

            foreach (AutomationTreeElementWrapper treeElem in rootWrapper.ChildList)
            {
                try
                {
                    TraverseElement(walker, treeElem);
                }
                catch (Exception)
                {
                    continue;
                }
            }
        }
Example #3
0
        private static void TraverseElement(TreeWalker walker, AutomationTreeElementWrapper automationElementWrapper)
        {
            Queue <AutomationTreeElementWrapper> elementQueue = new Queue <AutomationTreeElementWrapper>();

            elementQueue.Enqueue(automationElementWrapper);
            while (elementQueue.Count > 0)
            {
                AutomationTreeElementWrapper atew  = elementQueue.Dequeue();
                AutomationElement            child = walker.GetFirstChild(atew.AE);

                while (child != null)
                {
                    AutomationTreeElementWrapper caew = new AutomationTreeElementWrapper(child);
                    atew.AddChild(caew);
                    elementQueue.Enqueue(caew);
                    child = walker.GetNextSibling(child);
                }
            }
        }
Example #4
0
 public void AddChild(AutomationTreeElementWrapper aew)
 {
     this.ChildList.Add(aew);
 }