当前位置: 首页>>代码示例>>C#>>正文


C# IUiElement.FindAll方法代码示例

本文整理汇总了C#中IUiElement.FindAll方法的典型用法代码示例。如果您正苦于以下问题:C# IUiElement.FindAll方法的具体用法?C# IUiElement.FindAll怎么用?C# IUiElement.FindAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUiElement的用法示例。


在下文中一共展示了IUiElement.FindAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SearchByExactConditionsViaUia

 internal static List<IUiElement> SearchByExactConditionsViaUia(
     IUiElement inputObject,
     Hashtable[] searchCriteria,
     classic.Condition conditions)
 {
     if (conditions == null) return new List<IUiElement>();
     
     if (inputObject == null || (int) inputObject.GetCurrent().ProcessId <= 0) return new List<IUiElement>();
     
     IUiEltCollection tempCollection = inputObject.FindAll(classic.TreeScope.Descendants, conditions);
     
     if (null == searchCriteria || 0 == searchCriteria.Length) {
         return tempCollection.ToArray().ToList<IUiElement>();
     }
     
     return tempCollection.ToArray().Where(element => TestControlWithAllSearchCriteria(searchCriteria, element)).ToList<IUiElement>();
 }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:17,代码来源:ControlSearcher.cs

示例2: SearchByContainsTextViaUia

 internal static List<IUiElement> SearchByContainsTextViaUia(
     IUiElement inputObject,
     classic.Condition conditionsForTextSearch)
 {
     IUiEltCollection textSearchCollection = inputObject.FindAll(classic.TreeScope.Descendants, conditionsForTextSearch);
     return textSearchCollection.Cast<IUiElement>().ToList();
 }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:7,代码来源:ControlSearcher.cs

示例3: GetWindowCollectionByPid

 internal List<IUiElement> GetWindowCollectionByPid(
     IUiElement rootElement,
     WindowSearcherData data)
 {
     classic.AndCondition conditionsForRecurseSearch = null;
     
     var elementsByProcessId =
         new List<IUiElement>();
     
     // 20141001
     // if ((null != data.Name && 0 < data.Name.Count()) ||
     if ((null != data.Name && data.Name.Any()) ||
         !string.IsNullOrEmpty(data.AutomationId) ||
         !string.IsNullOrEmpty(data.Class)) {
         
         data.Recurse = true;
     }
     
     var conditionWindowPaneMenu =
         new classic.OrCondition(
             new classic.PropertyCondition(
                 classic.AutomationElement.ControlTypeProperty,
                 classic.ControlType.Window),
             new classic.PropertyCondition(
                 classic.AutomationElement.ControlTypeProperty,
                 classic.ControlType.Pane),
             new classic.PropertyCondition(
                 classic.AutomationElement.ControlTypeProperty,
                 classic.ControlType.Menu));
     
     foreach (int processId in data.ProcessIds) {
         
         conditionsForRecurseSearch =
             new classic.AndCondition(
                 new classic.PropertyCondition(
                     classic.AutomationElement.ProcessIdProperty,
                     processId),
                 new classic.PropertyCondition(
                     classic.AutomationElement.ControlTypeProperty,
                     classic.ControlType.Window));
             
         var conditionsProcessId =
             new classic.AndCondition(
                 new classic.PropertyCondition(
                     classic.AutomationElement.ProcessIdProperty,
                     processId),
                 conditionWindowPaneMenu);
         
         try {
             
             if (data.Recurse) {
                 if (data.First) {
                     
                     IUiElement rootWindowElement =
                         rootElement.FindFirst(
                             classic.TreeScope.Children,
                             conditionsProcessId);
                     
                     if (null != rootWindowElement) {
                         elementsByProcessId.Add(rootWindowElement);
                     }
                     
                 } else {
                     
                     IUiEltCollection rootCollection =
                         rootElement.FindAll(
                             classic.TreeScope.Children,
                             conditionsProcessId);
                     
                     if (null != rootCollection && 0 < rootCollection.Count)
                     {
                         elementsByProcessId.AddRange(rootCollection.Cast<IUiElement>());
                     }
                 }
                 
             } else {
                 
                 if (data.First) {
                     
                     IUiElement tempElement =
                         rootElement.FindFirst(
                             classic.TreeScope.Children,
                             conditionsProcessId);
                     
                     if (null != tempElement) {
                         
                         elementsByProcessId.Add(tempElement);
                     }
                 } else {
                     
                     IUiEltCollection tempCollection =
                         rootElement.FindAll(
                             classic.TreeScope.Children,
                             conditionsProcessId);
                     
                     if (null != tempCollection && 0 < tempCollection.Count) {
                         
                         elementsByProcessId.AddRange(tempCollection.Cast<IUiElement>());
                     }
                 }
//.........这里部分代码省略.........
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:101,代码来源:WindowSearcher.cs

示例4: GetAutomationElementsWithFindAll

 internal List<IUiElement> GetAutomationElementsWithFindAll(
     IUiElement element,
     ControlSearcherData data,
     classic.Condition conditions,
     bool caseSensitiveParam,
     bool onlyOneResult,
     bool onlyTopLevel,
     bool viaWildcardOrRegex)
 {
     var resultCollection = new List<IUiElement>();
     
     try {
         
         IUiEltCollection results =
             element.FindAll(
                 classic.TreeScope.Descendants,
                 conditions);
         
         resultCollection =
             WindowSearcher.ReturnOnlyRightElements(
                 results,
                 data,
                 caseSensitiveParam,
                 viaWildcardOrRegex);
         
         if (null != results) {
             // results.Dispose(); // taboo!
             results = null;
         }
         // results = null;
         
     }
     catch { //(Exception eWildCardSearch) {
         
     }
     
     return resultCollection;
 }
开发者ID:universsky,项目名称:STUPS,代码行数:38,代码来源:GetControlCollectionCmdletBase.cs

示例5: GetWindowCollectionByName

        List<IUiElement> GetWindowCollectionByName(
            IUiElement rootElement,
            WindowSearcherData data)
        {
            var windowCollectionByProperties =
                new List<IUiElement>();
            var resultCollection =
                new List<IUiElement>();
            
            if (null == data.Name) {
                // 20141001
                // data.Name = new string[]{ string.Empty };
                data.Name = new []{ string.Empty };
            }
            
            classic.OrCondition conditionsSet = null;
            if (data.Recurse) {
                conditionsSet =
                    new classic.OrCondition(
                        new classic.PropertyCondition(
                            classic.AutomationElement.ControlTypeProperty,
                            classic.ControlType.Window),
                        classic.Condition.FalseCondition);
            } else {
                conditionsSet =
                    new classic.OrCondition(
                        new classic.PropertyCondition(
                            classic.AutomationElement.ControlTypeProperty,
                            classic.ControlType.Window),
                        new classic.PropertyCondition(
                            classic.AutomationElement.ControlTypeProperty,
                            classic.ControlType.Pane),
                        new classic.PropertyCondition(
                            classic.AutomationElement.ControlTypeProperty,
                            classic.ControlType.Menu));
            }
            
            foreach (string windowTitle in data.Name) {
                
                IUiEltCollection windowCollection =
                    rootElement.FindAll(data.Recurse ? classic.TreeScope.Descendants : classic.TreeScope.Children, conditionsSet);
                
                var controlSearcherData =
                    new ControlSearcherData {
                    Name = windowTitle,
                    AutomationId = data.AutomationId,
                    Class = data.Class,
                    Value = string.Empty,
                    // 20141001
                    // ControlType = (new string[]{ "Window", "Pane", "Menu" })
                    ControlType = (new []{ "Window", "Pane", "Menu" })
                };
                
                windowCollectionByProperties =
                    ReturnOnlyRightElements(
                        windowCollection,
                        controlSearcherData,
                        false,
                        true);
                    
                try {
                    
                    if (null != windowCollectionByProperties && 0 < windowCollectionByProperties.Count) {
                        
                        foreach (IUiElement aeWndByTitle in windowCollectionByProperties
                            .Where(aeWndByTitle => aeWndByTitle != null && (int)aeWndByTitle.GetCurrent().ProcessId > 0))
                        {
                            resultCollection.Add(aeWndByTitle);
                        }
                        
                        windowCollectionByProperties.Clear();
                        
                    } else {
                        
                        IUiElement tempElement = null;
                        
                        // one more attempt using the FindWindow function
                        IntPtr wndHandle = NativeMethods.FindWindowByCaption(IntPtr.Zero, windowTitle);
                        // 20141001
                        // if (wndHandle != null && wndHandle != IntPtr.Zero) {
                        if (wndHandle != IntPtr.Zero) {
                            tempElement =
                                UiElement.FromHandle(wndHandle);
                        }
                        
                        if (null == tempElement || (int) tempElement.GetCurrent().ProcessId <= 0) continue;
                        
                        resultCollection.Add(tempElement);
                    }
                }
                catch {}
                
                // 20140122
                // AutomationFactory.DisposeChildKernel();
                
                // 20140131
//                if (null != windowCollectionByProperties && 0 < windowCollectionByProperties.Count) {
//                    foreach (IUiElement element in windowCollectionByProperties) {
//                        element.Dispose();
//                    }
//.........这里部分代码省略.........
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:101,代码来源:WindowSearcher.cs


注:本文中的IUiElement.FindAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。