Example #1
0
 public override void OnStartHook()
 {
     UsedSearchType = UsedSearchType.None;
     
     var data = SearcherData as ControlSearcherData;
     
     #region conditions
     notTextSearch = true;
     if (!string.IsNullOrEmpty(data.ContainsText) && !data.Regex) {
         
         notTextSearch = false;
         
         conditionsForTextSearch =
             GetTextSearchCondition(
                 data.ContainsText,
                 data.ControlType,
                 data.CaseSensitive);
         
     } else {
         
         conditionsForExactSearch = GetExactSearchCondition(data);
         
         conditionsForWildCards =
             GetWildcardSearchCondition(data);
     }
     #endregion conditions
     
     ResultCollection = new List<IUiElement>();            
 }
Example #2
0
        public override void OnStartHook()
        {
            UsedSearchType = UsedSearchType.None;

            var data = SearcherData as ControlSearcherData;

            #region conditions
            notTextSearch = true;
            if (!string.IsNullOrEmpty(data.ContainsText) && !data.Regex)
            {
                notTextSearch = false;

                conditionsForTextSearch =
                    GetTextSearchCondition(
                        data.ContainsText,
                        data.ControlType,
                        data.CaseSensitive);
            }
            else
            {
                conditionsForExactSearch = GetExactSearchCondition(data);

                conditionsForWildCards =
                    GetWildcardSearchCondition(data);
            }
            #endregion conditions

            ResultCollection = new List <IUiElement>();
        }
Example #3
0
 public override List<IUiElement> SearchForElements(SearcherTemplateData searchData)
 {
     if (null == ResultCollection) return new List<IUiElement>();
     if (null == searchData) return ResultCollection;
     
     var data = searchData as ControlSearcherData;
     
     if (null == data) return ResultCollection;
     if (null == data.InputObject) return ResultCollection;
     
     foreach (IUiElement inputObject in data.InputObject) {
         
         int processId = 0;
         
         #region checking processId
         if (inputObject != null &&
             // 20140312
             // (int)inputObject.Current.ProcessId > 0) {
             (int)inputObject.GetCurrent().ProcessId > 0) {
             
             // 20140312
             // processId = inputObject.Current.ProcessId;
             processId = inputObject.GetCurrent().ProcessId;
         }
         #endregion checking processId
         
         // 20130204
         // don't change the order! (text->exact->wildcard->win32 to win32->text->exact->wildcard)
         #region text search
         if (0 == ResultCollection.Count) {
             if (!notTextSearch && !data.Win32) {
                 
                 UsedSearchType = UsedSearchType.Control_TextSearch;
                 ResultCollection.AddRange(
                     SearchByContainsTextViaUia(
                         inputObject,
                         conditionsForTextSearch));
             }
         }
         #endregion text search
         
         #region text search Win32
         if (0 == ResultCollection.Count) {
             if (!notTextSearch && data.Win32) {
                 
                 UsedSearchType = UsedSearchType.Control_TextSearchWin32;
                 var controlFromWin32Provider = AutomationFactory.GetObject<ControlFromWin32Provider>();
                 controlFromWin32Provider.SearchData = data;
                 controlFromWin32Provider.HandleCollector = AutomationFactory.GetObject<HandleCollector>();
                 
                 ResultCollection.AddRange(
                     SearchByContainsTextViaWin32(
                         inputObject,
                         controlFromWin32Provider));
             }
         }
         #endregion text search Win32
         
         #region exact search
         if (0 == ResultCollection.Count && notTextSearch && !data.Regex) {
             if (!Preferences.DisableExactSearch && !data.Win32 ) {
                     
                     UsedSearchType = UsedSearchType.Control_ExactSearch;
                     ResultCollection.AddRange(
                         SearchByExactConditionsViaUia(
                             inputObject,
                             data.SearchCriteria,
                             conditionsForExactSearch));
             }
         }
         #endregion exact search
         
         #region wildcard search
         if (0 == ResultCollection.Count && notTextSearch && !data.Regex) {
             if (!Preferences.DisableWildCardSearch && !data.Win32) {
                     
                     UsedSearchType = UsedSearchType.Control_WildcardSearch;
                     ResultCollection.AddRange(
                         SearchByWildcardOrRegexViaUia(
                             inputObject,
                             data,
                             // 20140206
                             // UiElement.RootElement,
                             conditionsForWildCards,
                             true));
             }
         }
         #endregion wildcard search
         
         #region Regex search
         if (0 == ResultCollection.Count && notTextSearch && data.Regex) {
             if (!Preferences.DisableWildCardSearch && !data.Win32) {
                 
                 UsedSearchType = UsedSearchType.Control_RegexSearch;
                 ResultCollection.AddRange(
                     SearchByWildcardOrRegexViaUia(
                         inputObject,
                         data,
                         conditionsForWildCards,
                         false));
             }
         }
         #endregion Regex search
         
         #region Win32 search
         if (0 == ResultCollection.Count && notTextSearch && !data.Regex) {
             if (!Preferences.DisableWin32Search && data.Win32) {
                 
                 UsedSearchType = UsedSearchType.Control_Win32Search;
                 var handleCollector = AutomationFactory.GetObject<HandleCollector>();
                 
                 ResultCollection.AddRange(
                     SearchByWildcardViaWin32(
                         inputObject,
                         data,
                         handleCollector));
                 
             }
         } // FindWindowEx
         #endregion Win32 search                
     }
     
     return ResultCollection;
 }
Example #4
0
        public override List <IUiElement> SearchForElements(SearcherTemplateData searchData)
        {
            if (null == ResultCollection)
            {
                return(new List <IUiElement>());
            }
            if (null == searchData)
            {
                return(ResultCollection);
            }

            var data = searchData as ControlSearcherData;

            if (null == data)
            {
                return(ResultCollection);
            }
            if (null == data.InputObject)
            {
                return(ResultCollection);
            }

            foreach (IUiElement inputObject in data.InputObject)
            {
                int processId = 0;

                #region checking processId
                if (inputObject != null &&
                    // 20140312
                    // (int)inputObject.Current.ProcessId > 0) {
                    (int)inputObject.GetCurrent().ProcessId > 0)
                {
                    // 20140312
                    // processId = inputObject.Current.ProcessId;
                    processId = inputObject.GetCurrent().ProcessId;
                }
                #endregion checking processId

                // 20130204
                // don't change the order! (text->exact->wildcard->win32 to win32->text->exact->wildcard)
                #region text search
                if (0 == ResultCollection.Count)
                {
                    if (!notTextSearch && !data.Win32)
                    {
                        UsedSearchType = UsedSearchType.Control_TextSearch;
                        ResultCollection.AddRange(
                            SearchByContainsTextViaUia(
                                inputObject,
                                conditionsForTextSearch));
                    }
                }
                #endregion text search

                #region text search Win32
                if (0 == ResultCollection.Count)
                {
                    if (!notTextSearch && data.Win32)
                    {
                        UsedSearchType = UsedSearchType.Control_TextSearchWin32;
                        var controlFromWin32Provider = AutomationFactory.GetObject <ControlFromWin32Provider>();
                        controlFromWin32Provider.SearchData      = data;
                        controlFromWin32Provider.HandleCollector = AutomationFactory.GetObject <HandleCollector>();

                        ResultCollection.AddRange(
                            SearchByContainsTextViaWin32(
                                inputObject,
                                controlFromWin32Provider));
                    }
                }
                #endregion text search Win32

                #region exact search
                if (0 == ResultCollection.Count && notTextSearch && !data.Regex)
                {
                    if (!Preferences.DisableExactSearch && !data.Win32)
                    {
                        UsedSearchType = UsedSearchType.Control_ExactSearch;
                        ResultCollection.AddRange(
                            SearchByExactConditionsViaUia(
                                inputObject,
                                data.SearchCriteria,
                                conditionsForExactSearch));
                    }
                }
                #endregion exact search

                #region wildcard search
                if (0 == ResultCollection.Count && notTextSearch && !data.Regex)
                {
                    if (!Preferences.DisableWildCardSearch && !data.Win32)
                    {
                        UsedSearchType = UsedSearchType.Control_WildcardSearch;
                        ResultCollection.AddRange(
                            SearchByWildcardOrRegexViaUia(
                                inputObject,
                                data,
                                // 20140206
                                // UiElement.RootElement,
                                conditionsForWildCards,
                                true));
                    }
                }
                #endregion wildcard search

                #region Regex search
                if (0 == ResultCollection.Count && notTextSearch && data.Regex)
                {
                    if (!Preferences.DisableWildCardSearch && !data.Win32)
                    {
                        UsedSearchType = UsedSearchType.Control_RegexSearch;
                        ResultCollection.AddRange(
                            SearchByWildcardOrRegexViaUia(
                                inputObject,
                                data,
                                conditionsForWildCards,
                                false));
                    }
                }
                #endregion Regex search

                #region Win32 search
                if (0 == ResultCollection.Count && notTextSearch && !data.Regex)
                {
                    if (!Preferences.DisableWin32Search && data.Win32)
                    {
                        UsedSearchType = UsedSearchType.Control_Win32Search;
                        var handleCollector = AutomationFactory.GetObject <HandleCollector>();

                        ResultCollection.AddRange(
                            SearchByWildcardViaWin32(
                                inputObject,
                                data,
                                handleCollector));
                    }
                } // FindWindowEx
                #endregion Win32 search
            }

            return(ResultCollection);
        }