public override void AfterSearchHook() { // filtering result window collection by SearchCriteria if (null != ResultCollection && 0 < ResultCollection.Count) { if (null != (SearcherData as WindowSearcherData).SearchCriteria && 0 < (SearcherData as WindowSearcherData).SearchCriteria.Length) { ResultCollection = ResultCollection.GetFilteredElementsCollection(); } } // filtering result window collection by having a control(s) with properties as from WithControl if (null != ResultCollection && 0 < ResultCollection.Count) { if (null != (SearcherData as WindowSearcherData).WithControl && 0 < (SearcherData as WindowSearcherData).WithControl.Length) { FilterResultCollectionByWithControlParameter(); } } Wait &= !(SearcherData as WindowSearcherData).WaitNoWindow || !wasFound || (null != ResultCollection && 0 != ResultCollection.Count); // wasFound = true; // ResultCollection.Clear(); // ResultCollection = null; if ((SearcherData as WindowSearcherData).WaitNoWindow && !wasFound && null != ResultCollection && 0 != ResultCollection.Count) { wasFound = true; ResultCollection.Clear(); ResultCollection = null; } if (null != ResultCollection && 0 < ResultCollection.Count) { if (Preferences.CacheRequestCalled && null != CurrentData.CacheRequest) { try { // CurrentData.CacheRequest.Push(); // var cacheRequest = CurrentData.CacheRequest.Clone(); ClonedCacheRequest = CurrentData.CacheRequest.Clone(); ClonedCacheRequest.Push(); Preferences.FromCache = true; } catch (Exception) { Preferences.FromCache = false; //Console.WriteLine("failed to start cache request"); //Console.WriteLine(eeee.Message); } } } else { if (null == CurrentData.CacheRequest) { //Console.WriteLine("cache request is null"); } } }
public virtual classic.AutomationElement GetUpdatedCache(classic.CacheRequest request) { switch (_innerElementType) { case InnerElementTypes.AutomationElementNet: return(_elementHolderNet.GetUpdatedCache(request)); // case InnerElementTypes.AutomationElementCom: // // case InnerElementTypes.UiElement: return(_elementHolderAdapter.GetUpdatedCache(request)); default: return(_elementHolderNet.GetUpdatedCache(request)); } }
public override List <IUiElement> SearchForElements(SearcherTemplateData searchData) { // 20140208 if (Preferences.CacheRequestCalled && null != CurrentData.CacheRequest) { try { Preferences.FromCache = false; // CurrentData.CacheRequest.Pop(); ClonedCacheRequest = null; } catch (Exception) { //Console.WriteLine("failed to stop the cache request"); //Console.WriteLine(eeeee.Message); } } else { if (null == CurrentData.CacheRequest) { //Console.WriteLine("cache request is null"); } } try { var data = searchData as WindowSearcherData; // WindowSearcherData data = searchData as WindowSearcherData; AutomationFactory.InitializeChildKernel(); if (data.Win32) { if (null == ResultCollection || 0 == ResultCollection.Count) { ResultCollection = GetWindowCollectionViaWin32(data); } } else if (null != data.InputObject && data.InputObject.Length > 0) { if (null == ResultCollection || 0 == ResultCollection.Count) { ResultCollection = GetWindowCollectionFromProcess(data); } } else if (null != data.ProcessIds && data.ProcessIds.Length > 0) { if (null == ResultCollection || 0 == ResultCollection.Count) { ResultCollection = GetWindowCollectionByPid(UiElement.RootElement, data); } } else if (null != data.ProcessNames && data.ProcessNames.Length > 0) { if (null == ResultCollection || 0 == ResultCollection.Count) { // 20141001 // ResultCollection = GetWindowCollectionByProcessName(UiElement.RootElement, data); ResultCollection = GetWindowCollectionByProcessName(data); } } else if ((null != data.Name && data.Name.Length > 0) || !string.IsNullOrEmpty(data.AutomationId) || !string.IsNullOrEmpty(data.Class)) { if (null == ResultCollection || 0 == ResultCollection.Count) { ResultCollection = GetWindowCollectionByName(UiElement.RootElement, data); } } if (null == ResultCollection || 0 == ResultCollection.Count) { AutomationFactory.ChildKernel.Release(ResultCollection); } } catch (Exception) { // // throw; } return(ResultCollection); }
public override List<IUiElement> SearchForElements(SearcherTemplateData searchData) { // 20140208 if (Preferences.CacheRequestCalled && null != CurrentData.CacheRequest) { try { Preferences.FromCache = false; // CurrentData.CacheRequest.Pop(); ClonedCacheRequest = null; } catch (Exception) { //Console.WriteLine("failed to stop the cache request"); //Console.WriteLine(eeeee.Message); } } else { if (null == CurrentData.CacheRequest) { //Console.WriteLine("cache request is null"); } } try { var data = searchData as WindowSearcherData; // WindowSearcherData data = searchData as WindowSearcherData; AutomationFactory.InitializeChildKernel(); if (data.Win32) { if (null == ResultCollection || 0 == ResultCollection.Count) { ResultCollection = GetWindowCollectionViaWin32(data); } } else if (null != data.InputObject && data.InputObject.Length > 0) { if (null == ResultCollection || 0 == ResultCollection.Count) { ResultCollection = GetWindowCollectionFromProcess(data); } } else if (null != data.ProcessIds && data.ProcessIds.Length > 0) { if (null == ResultCollection || 0 == ResultCollection.Count) { ResultCollection = GetWindowCollectionByPid(UiElement.RootElement, data); } } else if (null != data.ProcessNames && data.ProcessNames.Length > 0) { if (null == ResultCollection || 0 == ResultCollection.Count) { // 20141001 // ResultCollection = GetWindowCollectionByProcessName(UiElement.RootElement, data); ResultCollection = GetWindowCollectionByProcessName(data); } } else if ((null != data.Name && data.Name.Length > 0) || !string.IsNullOrEmpty(data.AutomationId) || !string.IsNullOrEmpty(data.Class)) { if (null == ResultCollection || 0 == ResultCollection.Count) { ResultCollection = GetWindowCollectionByName(UiElement.RootElement, data); } } if (null == ResultCollection || 0 == ResultCollection.Count) { AutomationFactory.ChildKernel.Release(ResultCollection); } } catch (Exception) { // // throw; } return ResultCollection; }