Ejemplo n.º 1
0
 public void RemoveAutomationEventHandler(classic.AutomationEvent eventId, IUiElement element, classic.AutomationEventHandler eventHandler)
 {
     classic.Automation.RemoveAutomationEventHandler(
         eventId,
         element.GetSourceElement() as classic.AutomationElement,
         eventHandler);
 }
Ejemplo n.º 2
0
		public UiEltCollection(classic.AutomationElementCollection elements)
		{
		    foreach (classic.AutomationElement element in elements.Cast<classic.AutomationElement>().Where(element => null != element))
		    {
		        _collectionHolder.Add(AutomationFactory.GetUiElement(element));
		    }
		}
Ejemplo n.º 3
0
 public void AddAutomationPropertyChangedEventHandler(IUiElement element, classic.TreeScope scope, classic.AutomationPropertyChangedEventHandler eventHandler, params classic.AutomationProperty[] properties)
 {
     classic.Automation.AddAutomationPropertyChangedEventHandler(
         element.GetSourceElement() as classic.AutomationElement,
         scope,
         eventHandler,
         properties);
 }
Ejemplo n.º 4
0
 public void AddAutomationEventHandler(classic.AutomationEvent eventId, IUiElement element, classic.TreeScope scope, classic.AutomationEventHandler eventHandler)
 {
     classic.Automation.AddAutomationEventHandler(
         eventId,
         element.GetSourceElement() as classic.AutomationElement,
         scope,
         eventHandler);
 }
        public static IUiElement PerformSetDockPosition(this IUiElement element, classic.DockPosition dockPosition)
        {
//            try {
                element.GetCurrentPattern<IDockPattern>(classic.DockPattern.Pattern).SetDockPosition(dockPosition);
//            } catch (Exception eExtensionMethod) {
//                // 
//                // throw;
//            }
            return element;
        }
Ejemplo n.º 6
0
 public UiaExpandCollapsePattern(IUiElement element, classic.ExpandCollapsePattern expandCollapsePattern)
 {
     _expandCollapsePattern = expandCollapsePattern;
     _element = element;
     //this._useCache = useCache;
 }
Ejemplo n.º 7
0
 public UiElementInformation(classic.AutomationElement.AutomationElementInformation information)
 {
     _infoHolder = information;
 }
Ejemplo n.º 8
0
 public UiaTablePattern(IUiElement element, classic.TablePattern tablePattern)
 {
     _tablePattern = tablePattern;
     _element = element;
     //this._useCache = useCache;
 }
Ejemplo n.º 9
0
 public UiaSelectionPattern(IUiElement element, classic.SelectionPattern selectionPattern)
 {
     this._selectionPattern = selectionPattern;
     this._element = element;
     //this._useCache = useCache;
 }
Ejemplo n.º 10
0
 public UiaValuePattern(classic.ValuePattern valuePattern)
 {
     _valuePattern = valuePattern;
 }
Ejemplo n.º 11
0
 public UiaWindowPattern(IUiElement element, classic.WindowPattern windowPattern)
 {
     this._windowPattern = windowPattern;
     this._element = element;
     //this._useCache = useCache;
 }
Ejemplo n.º 12
0
//        private UiaWindowPattern(AutomationElement el, SafePatternHandle hPattern, bool cached) : base(el, hPattern)
//        {
//            this._hPattern = hPattern;
//            this._cached = cached;
//        }
        public virtual void SetWindowVisualState(classic.WindowVisualState state)
        {
            // UiaCoreApi.WindowPattern_SetWindowVisualState(this._hPattern, state);
            this._windowPattern.SetWindowVisualState(state);
        }
Ejemplo n.º 13
0
        internal void CallDockPatternForSet(PatternCmdletBase cmdlet, IUiElement control, IUiElement inputObject, classic.DockPosition position)
        {
//            try {
//                // 20131208
//                // DockPattern dockPattern = control.GetCurrentPattern(classic.DockPattern.Pattern) as DockPattern;
//                // DockPattern dockPattern = control.GetCurrentPattern<IDockPattern, DockPattern>(classic.DockPattern.Pattern) as DockPattern;
                // 20140102
            try {
                control.PerformSetDockPosition(position);
                if (PassThru) {
                    WriteObject(this, control);
                } else {
                    WriteObject(this, true);
                }
            }
            catch {
                WriteObject(this, false);
            }
//                IDockPattern dockPattern = control.GetCurrentPattern<IDockPattern>(classic.DockPattern.Pattern);
//                if (null != dockPattern) {
//                    dockPattern.SetDockPosition(position);
//                    
//                    if (PassThru && null != (inputObject as IUiElement)) {
//                        WriteObject(this, inputObject);
//                    } else {
//                        WriteObject(this, true);
//                    }
//                } else {
//                    WriteVerbose(this, "couldn't get DockPattern");
//                    WriteObject(this, false);
//                }
//            }
//            catch {
//                
//            }
        }
Ejemplo n.º 14
0
 public UiaTogglePattern(IUiElement element, classic.TogglePattern togglePattern)
 {
     _togglePattern = togglePattern;
     _element = element;
     //this._useCache = useCache;
 }
Ejemplo n.º 15
0
 protected bool checkNotNull(object objectToTest, classic.AutomationEventArgs e)
 {
     // 20131109
     //AutomationElement sourceElement;
     // 20131118
     //IUiElement sourceElement;
     /*
     AutomationElement sourceElement;
     */
     try {
         // 20131109
         //sourceElement = objectToTest as AutomationElement;
         // 20131118
         //sourceElement = objectToTest as IUiElement;
         classic.AutomationElement sourceElement = objectToTest as classic.AutomationElement;
         // 20131109
         //this.EventSource = sourceElement;
         // 20131118
         // property to method
         //this.EventSource = sourceElement.SourceElement;
         // 20131118
         //this.EventSource = sourceElement.GetSourceElement();
         EventSource = sourceElement;
         EventArgs = e;
     } 
     catch { //(ElementNotAvailableException eNotAvailable) {
         return false;
     }
     return true;
 }
Ejemplo n.º 16
0
 public UiaInvokePattern(classic.InvokePattern InvokePattern)
 {
     this._invokePattern = InvokePattern;
 }
Ejemplo n.º 17
0
 public UiaValuePattern(IUiElement element, classic.ValuePattern valuePattern)
 {
     _valuePattern = valuePattern;
     _element = element;
     //this._useCache = useCache;
 }
Ejemplo n.º 18
0
 public UiaRangeValuePattern(IUiElement element, classic.RangeValuePattern rangeValuePattern)
 {
     _rangeValuePattern = rangeValuePattern;
     _element = element;
     //this._useCache = useCache;
 }
 public static IUiElement PerformSetWindowVisualState(this IUiElement element, classic.WindowVisualState state)
 {
     try {
         element.GetCurrentPattern<IWindowPattern>(classic.WindowPattern.Pattern).SetWindowVisualState(state);
     } catch (Exception eExtensionMethod) {
         // 
         // throw;
     }
     return element;
 }
 public static IUiElement PerformSetDockPosition(this IUiElement element, classic.DockPosition dockPosition)
 {
     element.GetCurrentPattern<IDockPattern>(classic.DockPattern.Pattern).SetDockPosition(dockPosition);
     return element;
 }
 public static IUiElement PerformScrollVertical(this IUiElement element, classic.ScrollAmount amount)
 {
     try {
         element.GetCurrentPattern<IScrollPattern>(classic.ScrollPattern.Pattern).ScrollVertical(amount);
     } catch (Exception eExtensionMethod) {
         // 
         // throw;
     }
     return element;
 }
 public static IUiElement PerformScroll(this IUiElement element, classic.ScrollAmount horizontalAmount, classic.ScrollAmount verticalAmount)
 {
     try {
         element.GetCurrentPattern<IScrollPattern>(classic.ScrollPattern.Pattern).Scroll(horizontalAmount, verticalAmount);
     } catch (Exception) {
         // 
         // throw;
     }
     return element;
 }
Ejemplo n.º 23
0
 protected override void SaveEventInput(
     // 20131109
     classic.AutomationElement src,
     //IUiElement src,
     classic.AutomationEventArgs e,
     string programmaticName,
     bool infoAdded)
 {
     // inform the Wait-UiaEventRaised cmdlet
     try {
         // 20131109
         //CurrentData.LastEventSource = src; //.SourceElement; // as AutomationElement;
         // 20131112
         //CurrentData.LastEventSource = new UiElement(src);
         CurrentData.LastEventSource = AutomationFactory.GetUiElement(src);
         CurrentData.LastEventArgs = e; // as AutomationEventArgs;
         CurrentData.LastEventType = programmaticName;
         CurrentData.LastEventInfoAdded = infoAdded;
     }
     catch {
         //WriteVerbose(this, "failed to register an event in the collection");
     }
 }
Ejemplo n.º 24
0
 internal static List<IUiElement> SearchByContainsTextViaUia(
     IUiElement inputObject,
     classic.Condition conditionsForTextSearch)
 {
     IUiEltCollection textSearchCollection = inputObject.FindAll(classic.TreeScope.Descendants, conditionsForTextSearch);
     return textSearchCollection.Cast<IUiElement>().ToList();
 }
Ejemplo n.º 25
0
 /// <summary>
 ///  /// </summary>
 /// <param name="element"></param>
 /// <param name="scope"></param>
 /// <returns></returns>
 internal static IUiElement[] GetParentOrAncestor(this IUiElement element, classic.TreeScope scope)
 {
     var walker =
         new classic.TreeWalker(
             classic.Condition.TrueCondition);
     
     var ancestors =
         new List<IUiElement>();
     
     try {
         
         IUiElement testParent = AutomationFactory.GetUiElement(walker.GetParent(element.GetSourceElement() as classic.AutomationElement));
             
         if (scope == classic.TreeScope.Parent || scope == classic.TreeScope.Ancestors) {
             
             if (testParent.GetCurrent() != UiElement.RootElement.GetCurrent()) {
                 ancestors.Add(testParent);
             }
             
             if ((testParent.Equals(UiElement.RootElement) && testParent.GetCurrent().Equals(UiElement.RootElement.GetCurrent())) ||
                 scope == classic.TreeScope.Parent) {
                 return ancestors.ToArray();
             }
         }
         
         while (testParent != null &&
             (int)testParent.GetCurrent().ProcessId > 0 &&
             !testParent.GetCurrent().Equals(UiElement.RootElement.GetCurrent())) {
             
             testParent =
                 AutomationFactory.GetUiElement(walker.GetParent(testParent.GetSourceElement() as classic.AutomationElement));
             
             if (testParent != null &&
                 (int)testParent.GetCurrent().ProcessId > 0 &&
                 !testParent.GetCurrent().Equals(UiElement.RootElement.GetCurrent())) {
                 
                 ancestors.Add(testParent);
             } else {
                 break;
             }
         }
         return ancestors.ToArray();
     } catch {
         return ancestors.ToArray();
     }
 }
Ejemplo n.º 26
0
 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>();
 }
Ejemplo n.º 27
0
 public UiaGridItemPattern(IUiElement element, classic.GridItemPattern gridItemPattern)
 {
     this._gridItemPattern = gridItemPattern;
     this._element = element;
     //this._useCache = useCache;
 }
Ejemplo n.º 28
0
        internal static List<IUiElement> SearchByWildcardOrRegexViaUia(
            IUiElement inputObject,
            ControlSearcherData data,
            classic.Condition conditionsForWildCards,
            bool viaWildcardOrRegex)
        {
            var resultCollection =
                new List<IUiElement>();
            
            if (null == inputObject) return resultCollection;
            
            try {
                var controlSearcherData =
                    new ControlSearcherData {
                    InputObject = data.InputObject ?? (new UiElement[]{ (UiElement)UiElement.RootElement }),
                    Name = data.Name,
                    AutomationId = data.AutomationId,
                    Class = data.Class,
                    Value = data.Value,
                    ControlType = null != data.ControlType && 0 < data.ControlType.Length ? data.ControlType : (new string[] {}),
                    CaseSensitive = caseSensitive
                };
                
                var cmdlet1 = new GetControlCollectionCmdletBase(controlSearcherData);
                
                try {
                    
                    List<IUiElement> tempList =
                        cmdlet1.GetAutomationElementsViaWildcards_FindAll(
                            controlSearcherData,
                            inputObject,
                            conditionsForWildCards,
                            cmdlet1.CaseSensitive,
                            false,
                            false,
                            viaWildcardOrRegex);
                    
                    if (null == data.SearchCriteria || 0 == data.SearchCriteria.Length) {
                        
                        resultCollection.AddRange(tempList);
                    } else {
                        
                        foreach (IUiElement tempElement2 in tempList.Where(elt => TestControlWithAllSearchCriteria(data.SearchCriteria, elt))) {
                            resultCollection.Add(tempElement2);
                        }
                    }
                    
                    if (null != tempList) {
                        tempList.Clear();
                        tempList = null;
                    }
                    
                    return resultCollection;
                    
                } catch (Exception eUnexpected) {

                    (new GetControlCmdletBase()).WriteError(
                        new GetControlCmdletBase(),
                        "The input control or window has been possibly lost." +
                        eUnexpected.Message,
                        "UnexpectedError",
                        ErrorCategory.ObjectNotFound,
                        true);
                }
                
                cmdlet1 = null;
                
                return resultCollection;
                
            } catch (Exception eWildCardSearch) {

                (new GetControlCmdletBase()).WriteError(
                    new GetControlCmdletBase(),
                    "The input control or window has been possibly lost." +
                    eWildCardSearch.Message,
                    "UnexpectedError",
                    ErrorCategory.ObjectNotFound,
                    true);
                
                return resultCollection;
            }
        }
Ejemplo n.º 29
0
 public UiaExpandCollapsePattern(classic.ExpandCollapsePattern ExpandCollapsePattern)
 {
     _expandCollapsePattern = ExpandCollapsePattern;
 }
Ejemplo n.º 30
0
 public UiaInvokePattern(IUiElement element, classic.InvokePattern invokePattern)
 {
     this._invokePattern = invokePattern;
     this._element = element;
     //this._useCache = useCache;
 }