Esempio n. 1
0
 public void RemoveAutomationEventHandler(classic.AutomationEvent eventId, IUiElement element, classic.AutomationEventHandler eventHandler)
 {
     classic.Automation.RemoveAutomationEventHandler(
         eventId,
         element.GetSourceElement() as classic.AutomationElement,
         eventHandler);
 }
Esempio n. 2
0
 // Constructors
 public UiNavigation(IUiElement element)
     : base(element)
 {
     this.contents = new VolatileList <UiElement>(
         () => base.FindAll(By.ClassName("ListViewItem")),
         (item) => new UiElement(item));
 }
Esempio n. 3
0
        /// <summary>
        /// Properties the setter.
        /// </summary>
        /// <param name="targetControl">The target control.</param>
        /// <param name="props">The props.</param>
        private void PropertySetter(Control targetControl, IUiElement props)
        {
            targetControl.Name     = props.Name;
            targetControl.Enabled  = !props.ReadOnly;
            targetControl.TabIndex = props.TabOrder;
            targetControl.Location = new Point(props.Rect.X, props.Rect.Y);

            if ((targetControl as Label) != null)
            {
                targetControl.Text = props.Text;

                if (props.Rect.Width == -1)
                {
                    targetControl.AutoSize = true;
                }
                else
                {
                    targetControl.Width = props.Rect.Width;
                }
            }
            else if ((targetControl as TextBox) != null)
            {
                targetControl.Text  = props.Value;
                targetControl.Width = props.Rect.Width;
                ((TextBox)targetControl).MaxLength = props.MaxLength;
            }
        }
        internal static bool IsMatchWildcardPattern(
            this IUiElement elementInput,
            IList resultCollection,
            WildcardPattern wcPattern,
            string dataToCheck)
        {
            bool result = false;

            // 20140314
            // was an experiment
            // resultCollection = resultCollection ?? new List<IUiElement>();

            if (string.IsNullOrEmpty(dataToCheck))
            {
                return(result);
            }

            if (!wcPattern.IsMatch(dataToCheck))
            {
                return(result);
            }

            result = true;
            resultCollection.Add(elementInput);
            return(result);
        }
Esempio n. 5
0
 public void AddStructureChangedEventHandler(IUiElement element, classic.TreeScope scope, classic.StructureChangedEventHandler eventHandler)
 {
     classic.Automation.AddStructureChangedEventHandler(
         element.GetSourceElement() as classic.AutomationElement,
         scope,
         eventHandler);
 }
        public static bool GetIsValid(this IUiElement element)
        {
            if (null == element)
            {
                return(false);
            }

            if (null == element.GetSourceElement())
            {
                return(false);
            }

            try {
                var elementNet = element.GetSourceElement() as classic.AutomationElement;
                if (null != elementNet)
                {
                    try {
                        var testVariable = elementNet.Current.Name;
                    } catch (Exception) {
                        return(false);
                        // throw;
                    }

                    if (0 == elementNet.Current.ProcessId)
                    {
                        return(false);
                    }
                }
            }
            catch {}

            return(true);
        }
        private void SetupUiElement(IUiElement element)
        {
            _currentUiElement = element;
            _currentUiElement.SwitchUiElement += Element_SwitchUiElement;

            _mainContext.Grid = element.ElementContext.Grid;
        }
Esempio n. 8
0
 public void RemoveAutomationEventHandler(classic.AutomationEvent eventId, IUiElement element, classic.AutomationEventHandler eventHandler)
 {
     classic.Automation.RemoveAutomationEventHandler(
         eventId,
         element.GetSourceElement() as classic.AutomationElement,
         eventHandler);
 }
Esempio n. 9
0
        internal void CallDockPatternForGet(PatternCmdletBase cmdlet, IUiElement control, IUiElement inputObject)
        {
            try {
                WriteObject(this, control.GetDockPosition());
            } catch (Exception) {
                WriteObject(this, false);
                // throw;
            }
//            //dockPattern.Current.DockPosition
//            try {
//                // 20131208
//                // DockPattern dockPattern = control.GetCurrentPattern(classic.DockPattern.Pattern) as DockPattern;
//                // DockPattern dockPattern = control.GetCurrentPattern<IDockPattern, DockPattern>(classic.DockPattern.Pattern) as DockPattern;
//                IDockPattern dockPattern = control.GetCurrentPattern<IDockPattern>(classic.DockPattern.Pattern);
//                if (null != dockPattern) {
//                    WriteObject(this, dockPattern.Current.DockPosition);
//                } else {
//                    WriteVerbose(this, "couldn't get DockPattern");
//                    WriteObject(this, false);
//                }
//            }
//            catch {
//                
//            }
        }
Esempio n. 10
0
        internal static bool TestControlWithAllSearchCriteria(
            IEnumerable <Hashtable> hashtables,
            IUiElement element)
        {
            bool result = false;

            if (null == hashtables || 0 == hashtables.Count())
            {
                return(result);
            }

            foreach (Hashtable hashtable in hashtables)
            {
                result =
                    element.TestControlByPropertiesFromDictionary(
                        hashtable.ConvertHashtableToDictionary());

                if (result)
                {
                    if (Preferences.HighlightCheckedControl)
                    {
                        UiaHelper.HighlightCheckedControl(element);
                    }

                    return(result);
                }
            }

            return(result);
        }
Esempio n. 11
0
 // Constructors
 public UiComboBox(IUiElement element)
     : base(element)
 {
     this.listItems = new VolatileList <UiElement>(
         () => base.FindAll(By.ClassName("ComboBoxItem")),
         (item) => new UiElement(item));
 }
        public static string GetInfo(this IUiElement element)
        {
            string resultString = string.Empty;

            if (null == element)
            {
                return(resultString);
            }

            try {
                if (null == element.GetCurrent())
                {
                    return(resultString);
                }

                if (!string.IsNullOrEmpty(element.GetCurrent().Name))
                {
                    return(element.GetCurrent().Name);
                }
                if (!string.IsNullOrEmpty(element.GetCurrent().AutomationId))
                {
                    return(element.GetCurrent().AutomationId);
                }
                if (!string.IsNullOrEmpty(element.GetCurrent().ClassName))
                {
                    return(element.GetCurrent().ClassName);
                }
            } catch (Exception) {
                return(resultString);
            }

            return(resultString);
        }
Esempio n. 13
0
        public static List <IUiElement> GetResultList_TextSearch(IUiElement element, Condition conditions)
        {
            var resultListOfControls =
                ControlSearcher.SearchByContainsTextViaUia(element, conditions);

            return(resultListOfControls);
        }
Esempio n. 14
0
 // 20140210
 internal static IExtendedModelHolder GetExtendedModelHolder(this IUiElement element, classic.TreeScope scope)
 // internal static IExtendedModelHolder GetExtendedModelHolder(this IUiElement element, TreeScope scope, int seconds)
 {
     // 20140210
     return(AutomationFactory.GetUiExtendedModelHolder(element, scope));
     // return AutomationFactory.GetUiExtendedModelHolder(element, scope, seconds);
 }
        protected internal IUiElement GetActiveWindow()
        {
            IUiElement result = null;

            try {
                IntPtr hWnd =
                    NativeMethods.GetForegroundWindow();

                if (hWnd == IntPtr.Zero)
                {
                    return(result);
                }

                result =
                    AutomationFactory.GetUiElement(classic.AutomationElement.FromHandle(hWnd));
                WriteVerbose(
                    this,
                    "the active window element is " +
                    // 20140312
                    // result.Current.Name);
                    result.GetCurrent().Name);
            } catch (Exception e) {
                WriteVerbose(this, e.Message);
            }
            return(result);
        }
 protected internal string ConvertElementToSearchCriteria(IUiElement element)
 {
     string result = "@{";
     result += GetPropertyCompleteString(element, result, "Name");
     result += GetPropertyCompleteString(element, result, "AutomationId");
     result += GetPropertyCompleteString(element, result, "ControlType");
     result += GetPropertyCompleteString(element, result, "Class");
     result += GetPropertyCompleteString(element, result, "AcceleratorKey");
     result += GetPropertyCompleteString(element, result, "AccessKey");
     result += GetPropertyCompleteString(element, result, "BoundingRectangle");
     result += GetPropertyCompleteString(element, result, "FrameworkId");
     result += GetPropertyCompleteString(element, result, "HasKeyboardFocus");
     result += GetPropertyCompleteString(element, result, "HelpText");
     result += GetPropertyCompleteString(element, result, "IsContentElement");
     result += GetPropertyCompleteString(element, result, "IsControlElement");
     result += GetPropertyCompleteString(element, result, "IsEnabled");
     result += GetPropertyCompleteString(element, result, "IsKeyboardFocusable");
     result += GetPropertyCompleteString(element, result, "IsOffscreen");
     result += GetPropertyCompleteString(element, result, "IsPassword");
     result += GetPropertyCompleteString(element, result, "IsRequiredForForm");
     result += GetPropertyCompleteString(element, result, "ItemStatus");
     result += GetPropertyCompleteString(element, result, "ItemType");
     //result += getPropertyCompleteString(inputObject, result, "LabeledBy");
     result += GetPropertyCompleteString(element, result, "LocalizedControlType");
     result += GetPropertyCompleteString(element, result, "NativeWindowHandle");
     result += GetPropertyCompleteString(element, result, "Orientation");
     result += GetPropertyCompleteString(element, result, "ProcessId");
     result += GetPatternStrings(element);
     result += "}";
     
     return result;
 }
Esempio n. 17
0
        internal static IEnumerable <IUiElement> SearchByContainsTextViaWin32(
            IUiElement inputObject,
            ControlFromWin32Provider controlProvider)
        {
            var resultList =
                new List <IUiElement>();

            foreach (IUiElement elementToChoose in controlProvider.GetElements(null))
            {
                if (null != controlProvider.SearchData.ControlType && 0 < controlProvider.SearchData.ControlType.Length)
                {
                    foreach (string controlTypeName in controlProvider.SearchData.ControlType)
                    {
                        // 20140312
                        // if (!String.Equals(elementToChoose.Current.ControlType.ProgrammaticName.Substring(12), controlTypeName, StringComparison.CurrentCultureIgnoreCase)) {
                        if (!String.Equals(elementToChoose.GetCurrent().ControlType.ProgrammaticName.Substring(12), controlTypeName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            continue;
                        }
                        else
                        {
                            resultList.Add(elementToChoose);
                            break;
                        }
                    }
                }
                else
                {
                    resultList.Add(elementToChoose);
                }
            }

            return(resultList);
        }
 public static Hashtable ConvertToHashtable(this IUiElement element)
 {
     return(new Hashtable
     {
         { "Name", element.GetCurrent().Name },
         { "AutomationId", element.GetCurrent().AutomationId },
         { "ControlType", element.GetCurrent().ControlType.ProgrammaticName },
         { "Class", element.GetCurrent().ClassName },
         { "AcceleratorKey", element.GetCurrent().AcceleratorKey },
         { "AccessKey", element.GetCurrent().AccessKey },
         { "BoundingRectangle", element.GetCurrent().BoundingRectangle.ToString() },
         { "FrameworkId", element.GetCurrent().FrameworkId },
         { "HasKeyboardFocus", element.GetCurrent().HasKeyboardFocus.ToString() },
         { "HelpText", element.GetCurrent().HelpText },
         { "IsContentElement", element.GetCurrent().IsContentElement.ToString() },
         { "IsControlElement", element.GetCurrent().IsControlElement.ToString() },
         { "IsEnabled", element.GetCurrent().IsEnabled.ToString() },
         { "IsKeyboardFocusable", element.GetCurrent().IsKeyboardFocusable.ToString() },
         { "IsOffscreen", element.GetCurrent().IsOffscreen.ToString() },
         { "IsPassword", element.GetCurrent().IsPassword.ToString() },
         { "IsRequiredForForm", element.GetCurrent().IsRequiredForForm.ToString() },
         { "ItemStatus", element.GetCurrent().ItemStatus },
         { "ItemType", element.GetCurrent().ItemType },
         { "LocalizedControlType", element.GetCurrent().LocalizedControlType },
         { "NativeWindowHandle", element.GetCurrent().NativeWindowHandle.ToString() },
         { "Orientation", element.GetCurrent().Orientation.ToString() },
         { "ProcessId", element.GetCurrent().ProcessId.ToString() }
     });
 }
Esempio n. 19
0
        public static List <IUiElement> Win32Gateway_GetElements_NullControlSearcherDataInput(
            IUiElement rootElement,
            IUiElement[] elements,
            IEnumerable <int> handles,
            string searchString)
        {
            var controlProvider     = new ControlFromWin32Provider();
            var controlSearcherData = new ControlSearcherTemplateData {
                ContainsText = searchString,
                Name         = searchString,
                Win32        = true,
                InputObject  = new IUiElement[] { rootElement }
            };

            controlProvider.SearchData = controlSearcherData;

            var handleCollector = FakeFactory.GetHandleCollector(rootElement, handles, elements);

            controlProvider.HandleCollector = handleCollector;

            List <IUiElement> resultList =
                controlProvider.GetElements(
                    null);

            return(resultList);
        }
Esempio n. 20
0
        /// <summary>
        /// Processes the attribute.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="attributeName">Name of the attribute.</param>
        /// <param name="node">The node.</param>
        private void ProcessAttribute(XElement element, string attributeName, IUiElement node)
        {
            XAttribute attr;
            var        flag = BindingFlags.SetProperty | BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public;

            if ((attr = element.Attribute(attributeName)) != null)
            {
                var type = node.GetType();
                var prop = type.GetProperties(flag).FirstOrDefault(x => string.Equals(attributeName,
                                                                                      x.Name, StringComparison.OrdinalIgnoreCase));

                if (prop != null)
                {
                    SetProperty(prop, node, attr.Value, prop.PropertyType);

                    // Set value (if metadata for selected file exists)
                    if (FileMetadata.Metadata != null)
                    {
                        var attributeVal = element.Attribute("name");
                        var attributes   = FileMetadata.Metadata.Elements("MetaFS-Data")
                                           .Elements("Data").Elements("UIElement").Attributes("name");

                        if (attributes.Any() && attributeVal != null)
                        {
                            var fieldValue = attributes.FirstOrDefault(x => string.Equals(x.Value,
                                                                                          attributeVal.Value, StringComparison.OrdinalIgnoreCase));
                            node.Value = fieldValue != null?fieldValue.Parent.Attribute("value").Value : string.Empty;
                        }
                    }
                }
            }
        }
Esempio n. 21
0
        private string GetPatternStrings(IUiElement element)
        {
            string result = string.Empty;

            if (!Full)
            {
                return(result);
            }

            IBasePattern[] supportedPatterns =
                element.GetSupportedPatterns();

            if (null == supportedPatterns || 0 == supportedPatterns.Length)
            {
                return(result);
            }

            foreach (IBasePattern pattern in supportedPatterns)
            {
                result += ";Has";
                result +=
                    // (pattern.GetSourcePattern() as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", string.Empty);
                    pattern.GetType().Name.Substring(2);
                result += "=$true";
            }

            return(result);
        }
Esempio n. 22
0
        protected internal string ConvertElementToSearchCriteria(IUiElement element)
        {
            string result = "@{";

            result += GetPropertyCompleteString(element, result, "Name");
            result += GetPropertyCompleteString(element, result, "AutomationId");
            result += GetPropertyCompleteString(element, result, "ControlType");
            result += GetPropertyCompleteString(element, result, "Class");
            result += GetPropertyCompleteString(element, result, "AcceleratorKey");
            result += GetPropertyCompleteString(element, result, "AccessKey");
            result += GetPropertyCompleteString(element, result, "BoundingRectangle");
            result += GetPropertyCompleteString(element, result, "FrameworkId");
            result += GetPropertyCompleteString(element, result, "HasKeyboardFocus");
            result += GetPropertyCompleteString(element, result, "HelpText");
            result += GetPropertyCompleteString(element, result, "IsContentElement");
            result += GetPropertyCompleteString(element, result, "IsControlElement");
            result += GetPropertyCompleteString(element, result, "IsEnabled");
            result += GetPropertyCompleteString(element, result, "IsKeyboardFocusable");
            result += GetPropertyCompleteString(element, result, "IsOffscreen");
            result += GetPropertyCompleteString(element, result, "IsPassword");
            result += GetPropertyCompleteString(element, result, "IsRequiredForForm");
            result += GetPropertyCompleteString(element, result, "ItemStatus");
            result += GetPropertyCompleteString(element, result, "ItemType");
            //result += getPropertyCompleteString(inputObject, result, "LabeledBy");
            result += GetPropertyCompleteString(element, result, "LocalizedControlType");
            result += GetPropertyCompleteString(element, result, "NativeWindowHandle");
            result += GetPropertyCompleteString(element, result, "Orientation");
            result += GetPropertyCompleteString(element, result, "ProcessId");
            result += GetPatternStrings(element);
            result += "}";

            return(result);
        }
Esempio n. 23
0
        public InventoryMerchantPane(MerchantId id)
        {
            var slotSpans = new IUiElement[InventoryHeight];

            for (int j = 0; j < InventoryHeight; j++)
            {
                var slotsInRow = new IUiElement[InventoryWidth];
                for (int i = 0; i < InventoryWidth; i++)
                {
                    int index = j * InventoryWidth + i;
                    slotsInRow[i] = new LogicalInventorySlot(new InventorySlotId(
                                                                 InventoryType.Merchant,
                                                                 (ushort)id,
                                                                 (ItemSlotId)((int)ItemSlotId.Slot0 + index)));
                }
                slotSpans[j] = new HorizontalStack(slotsInRow);
            }

            var slotStack     = new VerticalStack(slotSpans);
            var slotHalfFrame = new ButtonFrame(slotStack)
            {
                Theme = ButtonTheme.InventoryOuterFrame, Padding = -1
            };
            var header = new Header(new StringId(AssetType.SystemText, 0, (int)SystemTextId.Shop_Merchant));
            var stack  = new VerticalStack(header, slotHalfFrame)
            {
                Greedy = false
            };

            AttachChild(stack);
        }
        void ChangePage()
        {
            var pageId = _getPage();

            if (pageId == _lastPage)
            {
                return;
            }

            _lastPage = pageId;
            foreach (var child in Children)
            {
                child.Detach();
            }
            Children.Clear();

            IUiElement page = pageId switch
            {
                InventoryPage.Summary => new InventorySummaryPage(_activeCharacter),
                InventoryPage.Stats => new InventoryStatsPage(_activeCharacter),
                InventoryPage.Misc => new InventoryMiscPage(_activeCharacter),
                InventoryPage x => throw new NotImplementedException($"Unhandled inventory page \"{x}\"")
            };

            Children.Add(page);
            page.Attach(Exchange);
        }
Esempio n. 25
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);

            _startPointClick = e.GetPosition(this);
            var element = GetElement(_startPointClick);

            if (element == null)
            {
                if (e.ClickCount == 2)
                {
                    _graphViewModel.AddVertex(_startPointClick);
                    return;
                }

                if (!Keyboard.IsKeyDown(Key.RightCtrl) && !Keyboard.IsKeyDown(Key.LeftCtrl))
                {
                    _graphViewModel.UnselectElements();
                }
            }
            // Select element
            else
            {
                if (!_graphViewModel.SelectedElements.Contains(element.Id))
                {
                    AddSelectedElement(element, false);
                }
                _targetUiElement = element;
            }

            CaptureMouse();
            base.OnMouseLeftButtonDown(e);
        }
Esempio n. 26
0
        public static string WritingAvailablePatterns(IUiElement element)
        {
            string resultString = string.Empty;

            try {
                resultString  = "available patterns";
                resultString += "\r\n";

                // 20120618 UiaCOMWrapper
                // 20131209
                // AutomationPattern[] supportedPatterns =
                //     element.GetSupportedPatterns();

                IBasePattern[] supportedPatterns =
                    element.GetSupportedPatterns();
                //UiaCOM::System.Windows.Automation.AutomationPattern[] supportedPatterns =
                //    element.GetSupportedPatterns();

                if (supportedPatterns == null || supportedPatterns.Length <= 0)
                {
                    return(resultString);
                }

                for (int i = 0; i < supportedPatterns.Length; i++)
                {
                    if (i > 0)
                    {
                        resultString += "\r\n";
                    }

                    resultString +=
                        // 20131209
                        // supportedPatterns[i].ProgrammaticName.Replace("Identifiers.Pattern", "");
                        // 20131210
                        // (supportedPatterns[i] as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", "");
                        // (supportedPatterns[i].SourcePattern as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", "");
                        // 20140112
                        // (supportedPatterns[i].GetSourcePattern() as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", string.Empty);
                        supportedPatterns[i].GetType().Name.Substring(3);
                }

                /*
                 * if (supportedPatterns != null &&
                 *  supportedPatterns.Length > 0) {
                 *  for (int i = 0; i < supportedPatterns.Length; i++) {
                 *      if (i > 0) {
                 *          this.richPatterns.Text += "\r\n";
                 *      }
                 *      this.richPatterns.Text +=
                 *          supportedPatterns[i].ProgrammaticName.Replace("Identifiers.Pattern", "");
                 *  }
                 * }
                 */
                return(resultString);
            }
            catch {
                return(resultString);
            }
        }
Esempio n. 27
0
        internal static List <IUiElement> SearchByContainsTextViaUia(
            IUiElement inputObject,
            classic.Condition conditionsForTextSearch)
        {
            IUiEltCollection textSearchCollection = inputObject.FindAll(classic.TreeScope.Descendants, conditionsForTextSearch);

            return(textSearchCollection.Cast <IUiElement>().ToList());
        }
Esempio n. 28
0
        // Constructors
        public UiInterval(IUiElement element, UiChart chart)
            : base(element)
        {
            this.Chart = chart;

            this.start = new VolatileState <TimeSpan>(this.GetStart);
            this.span  = new VolatileState <TimeSpan>(this.GetSpan);
        }
Esempio n. 29
0
 public Padding(IUiElement content, int top, int right, int bottom, int left)
 {
     _left   = left;
     _right  = right;
     _top    = top;
     _bottom = bottom;
     AttachChild(content);
 }
Esempio n. 30
0
 public Child(IUiElement element, int x, int y, int?width, int?height)
 {
     Element = element;
     X       = x;
     Y       = y;
     Width   = width;
     Height  = height;
 }
Esempio n. 31
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);
 }
Esempio n. 32
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);
 }
Esempio n. 33
0
        private IVertexElement GetVertexElement(Point p)
        {
            _targetUiElement = null;
            HitTestResultCallback callback = HitTestClickCallback;

            VisualTreeHelper.HitTest(this, null, callback, new PointHitTestParameters(p));
            return(_targetUiElement as IVertexElement);
        }
Esempio n. 34
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);
 }
Esempio n. 35
0
        internal static void MoveCursorToControlPosition(this IUiElement element)
        {
            element.SetFocus();

            InputSimulator.Mouse.MoveMouseTo(
                (element.GetCurrent().BoundingRectangle.X + Preferences.ClickOnControlByCoordX) / Screen.PrimaryScreen.Bounds.Width * 65535,
                (element.GetCurrent().BoundingRectangle.Y + Preferences.ClickOnControlByCoordY) / Screen.PrimaryScreen.Bounds.Height * 65535);
        }
Esempio n. 36
0
 public static List<IUiElement> GetResultList_ExactSearch(IUiElement element, Condition conditions, Hashtable[] searchCriteria)
 {
     var resultListOfControls =
         ControlSearcher.SearchByExactConditionsViaUia(
             element,
             searchCriteria,
             conditions);
     return resultListOfControls;
 }
Esempio n. 37
0
        public static string WritingAvailablePatterns(IUiElement element)
        {
            string resultString = string.Empty;
            
            try {
                resultString = "available patterns";
                resultString += "\r\n";
                
                // 20120618 UiaCOMWrapper
                // 20131209
                // AutomationPattern[] supportedPatterns =
                //     element.GetSupportedPatterns();
                
                IBasePattern[] supportedPatterns =
                    element.GetSupportedPatterns();
                //UiaCOM::System.Windows.Automation.AutomationPattern[] supportedPatterns =
                //    element.GetSupportedPatterns();                                    

                if (supportedPatterns == null || supportedPatterns.Length <= 0) return resultString;
                
                for (int i = 0; i < supportedPatterns.Length; i++) {
                    if (i > 0) {
                        resultString += "\r\n";
                    }
                    
                    resultString +=
                        // 20131209
                        // supportedPatterns[i].ProgrammaticName.Replace("Identifiers.Pattern", "");
                        // 20131210
                        // (supportedPatterns[i] as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", "");
                        // (supportedPatterns[i].SourcePattern as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", "");
                        // 20140112
                        // (supportedPatterns[i].GetSourcePattern() as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", string.Empty);
                        supportedPatterns[i].GetType().Name.Substring(3);
                }

                /*
                if (supportedPatterns != null &&
                    supportedPatterns.Length > 0) {
                    for (int i = 0; i < supportedPatterns.Length; i++) {
                        if (i > 0) {
                            this.richPatterns.Text += "\r\n";
                        }
                        this.richPatterns.Text += 
                            supportedPatterns[i].ProgrammaticName.Replace("Identifiers.Pattern", "");
                    }
                }
                */
               return resultString;
            }
            catch {
                return resultString;
            }
        }
Esempio n. 38
0
 public static List<IUiElement> GetResultList_ViaWildcards(IUiElement element, Condition condition, ControlSearcherData data)
 {
     List<IUiElement> resultList =
         ControlSearcher.SearchByWildcardOrRegexViaUia(
             element,
             data,
             condition,
             true);
     
     return resultList;
 }
Esempio n. 39
0
 public static List<IUiElement> SearchByContainsTextViaWin32(
 	IUiElement inputObject,
     string containsText,
     string[] controlTypeNames,
     IEnumerable<IUiElement> collection,
     IEnumerable<int> handles)
 {
 	var singleControlSearcherData = new SingleControlSearcherData { Name = containsText, ControlType = controlTypeNames };
 	var controlProvider = FakeFactory.GetControlFromWin32Provider_old(collection, singleControlSearcherData);
 	
 	controlProvider.HandleCollector = FakeFactory.GetHandleCollector(inputObject, new int[] {}, collection.ToArray());
 	return ControlSearcher.SearchByContainsTextViaWin32(inputObject, controlProvider).ToList();
 }
Esempio n. 40
0
 public GetControlCmdletBase()
 {
     Class = string.Empty;
     Name = string.Empty;
     AutomationId = string.Empty;
     Value = string.Empty;
     
     InputObject =
         new IUiElement[] { CurrentData.CurrentWindow };
     
     // CacheRequest
     FromCache = Preferences.FromCache;
     
     Regex = false;
 }
Esempio n. 41
0
 public static List<IUiElement> GetResultList_ViaWildcards_Legacy(IUiElement element, Condition condition, ControlSearcherData data)
 {
     var cmdletDerived = new GetControlCollectionCmdletBase();
     
     List<IUiElement> resultList =
         cmdletDerived.GetAutomationElementsWithFindAll(
             element,
             data,
             condition,
             false,
             false,
             false,
             true);
     
     return resultList;
 }
 public void Buttons_Descendants_None()
 {
     // Arrange
     var elements = new IUiElement[] {};
     IUiElement element =
         FakeFactory.GetElement_ForFindAll(
             elements,
             new PropertyCondition(
                 AutomationElement.ControlTypeProperty,
                 ControlType.Button));
     
     // Act
     var resultCollection = ((element as ISupportsExtendedModel).Descendants as IExtendedModel).Buttons;
     
     // Assert
     MbUnit.Framework.Assert.AreEqual(AutomationFactory.GetUiEltCollection(elements), resultCollection);
     Xunit.Assert.Equal(AutomationFactory.GetUiEltCollection(elements), resultCollection);
 }
 private IUiElement TestElementsCollectionOfCertainType(ControlType controlType, out IUiElement[] elements)
 {
     // Arrange
     IUiElement[] elementsArray =
         new[] {
             FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, string.Empty, string.Empty),
             FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, string.Empty, string.Empty),
             FakeFactory.GetAutomationElementExpected(controlType, string.Empty, string.Empty, string.Empty, string.Empty)
         };
     elements = elementsArray;
     IUiElement element =
         FakeFactory.GetElement_ForFindAll(
             elements,
             new PropertyCondition(
                 AutomationElement.ControlTypeProperty,
                 controlType));
     
     return element;
 }
Esempio n. 44
0
 public virtual List<IntPtr> CollectRecursively(
     IUiElement containerElement,
     string name,
     int level)
 {
     var resultHandle = IntPtr.Zero;
     var controlHandle = IntPtr.Zero;
     var controlHandles = new List<IntPtr>();
     var tempControlHandles = new List<IntPtr>();
     // 20140312
     // var containerHandle = new IntPtr(containerElement.Current.NativeWindowHandle);
     var containerHandle = new IntPtr(containerElement.GetCurrent().NativeWindowHandle);
     
     if (containerHandle == IntPtr.Zero) return controlHandles;
     
     // search at this level
     do {
         // using null instead of name
         controlHandle =
             NativeMethods.FindWindowEx(containerHandle, controlHandle, null, null);
         
         if (controlHandle == IntPtr.Zero) continue;
         controlHandles.Add(controlHandle);
         
         tempControlHandles =
             CollectRecursively(
                 UiElement.FromHandle(controlHandle),
                 name,
                 level + 1);
         
         if (null == tempControlHandles || 0 == tempControlHandles.Count) continue;
         controlHandles.AddRange(tempControlHandles);
         
     } while (controlHandle != IntPtr.Zero);
     
     return controlHandles;
 }
Esempio n. 45
0
 public UiaGridItemPattern(IUiElement element, classic.GridItemPattern gridItemPattern)
 {
     this._gridItemPattern = gridItemPattern;
     this._element = element;
     //this._useCache = useCache;
 }
Esempio n. 46
0
        protected internal void WaitIfCondition(
            IUiElement _control,
            bool isEnabledOrIsVisible)
        {
            _control = InputObject.Cast<IUiElement>().ToArray()[0];
            
            // 20140312
//            if (isEnabledOrIsVisible) {
//                Wait = !(_control.Current).IsEnabled;
//            } else {
//                Wait = (_control.Current).IsOffscreen;
//            }
			Wait = isEnabledOrIsVisible ? !(_control.GetCurrent()).IsEnabled : (_control.GetCurrent()).IsOffscreen;
            do
            {
                SleepAndRunScriptBlocks(this);
                
                DateTime nowDate = DateTime.Now;
                try {
                    string tempIsReport = string.Empty;
                    // 20140312
                    // tempIsReport = isEnabledOrIsVisible ? _control.Current.IsEnabled.ToString() : _control.Current.IsOffscreen.ToString();
                    tempIsReport = isEnabledOrIsVisible ? _control.GetCurrent().IsEnabled.ToString() : _control.GetCurrent().IsOffscreen.ToString();
                    
                } catch { }
                if (!CheckAndPrepareInput(this))
                {
                    WriteObject(this, false);
                    
                    WriteError(
                        this,
                        "An unknown error while checking the control.",
                        "CheckingControl",
                        ErrorCategory.InvalidResult,
                        true);
                    
                    return;
                }
                
                // 20140312
//                if (isEnabledOrIsVisible) {
//                    Wait = !(_control.Current).IsEnabled;
//                } else {
//                    Wait = (_control.Current).IsOffscreen;
//                }
				Wait = isEnabledOrIsVisible ? !(_control.GetCurrent()).IsEnabled : (_control.GetCurrent()).IsOffscreen;
                if ((nowDate - StartDate).TotalSeconds > Timeout / 1000)
                {
                    // 20140312
//                    WriteVerbose(this, "timeout expired for AutomationId: " + 
//                                 _control.Current.AutomationId +
//                                ", title: " +
//                                 _control.Current.Name);
                    // 20140312
//                    WriteError(
//                        this,
//                        CmdletName(this) + ": timeout expired for AutomationId: " + 
//                        _control.Current.AutomationId +
//                        ", title: " +
//                        _control.Current.Name,
//                        "TimeoutExpired",
//                        ErrorCategory.OperationTimeout,
//                        true);
                    WriteError(
                        this,
                        CmdletName(this) + ": timeout expired for AutomationId: " + 
                        _control.GetCurrent().AutomationId +
                        ", title: " +
                        _control.GetCurrent().Name,
                        "TimeoutExpired",
                        ErrorCategory.OperationTimeout,
                        true);
                }
                if (_control != null) continue;
                
            } while (Wait);
        }
Esempio n. 47
0
 public static void SetCurrentWindow(IUiElement window)
 {
     CurrentWindow = window ?? null;
 }
Esempio n. 48
0
 public UiaSelectionPattern(IUiElement element, classic.SelectionPattern selectionPattern)
 {
     this._selectionPattern = selectionPattern;
     this._element = element;
     //this._useCache = useCache;
 }
 public UiaExpandCollapsePattern(IUiElement element)
 {
     _element = element;
 }
Esempio n. 50
0
 public UiaInvokePattern(IUiElement element, classic.InvokePattern invokePattern)
 {
     this._invokePattern = invokePattern;
     this._element = element;
     //this._useCache = useCache;
 }
Esempio n. 51
0
 public UiaInvokePattern(IUiElement element)
 {
     this._element = element;
 }
Esempio n. 52
0
 public UiaValuePattern(IUiElement element, classic.ValuePattern valuePattern)
 {
     _valuePattern = valuePattern;
     _element = element;
     //this._useCache = useCache;
 }
Esempio n. 53
0
 public UiaValuePattern(IUiElement element)
 {
     _element = element;
     _patternEmulator = new SourcePatternEmulator(new object());
 }
Esempio n. 54
0
 public UiaSelectionPattern(IUiElement element)
 {
     this._element = element;
 }
Esempio n. 55
0
 public UiaGridItemPattern(IUiElement element)
 {
     this._element = element;
 }
Esempio n. 56
0
 public UiaTablePattern(IUiElement element, classic.TablePattern tablePattern)
 {
     _tablePattern = tablePattern;
     _element = element;
     //this._useCache = useCache;
 }
 public UiaExpandCollapsePattern(IUiElement element, classic.ExpandCollapsePattern expandCollapsePattern)
 {
     _expandCollapsePattern = expandCollapsePattern;
     _element = element;
     //this._useCache = useCache;
 }
Esempio n. 58
0
 public UiaTablePattern(IUiElement element)
 {
     _element = element;
 }
 public void SetParentElement(IUiElement element)
 {
     _element = element;
 }
		public static classic.Text.TextPatternRange PerformRangeFromChild(this IUiElement element, IUiElement childElement)
		{
		    try {
		        return element.GetCurrentPattern<ITextPattern>(classic.TextPattern.Pattern).RangeFromChild(childElement);
            } catch (Exception eExtensionMethod) {
                // 
                // throw;
                // Console.WriteLine(eExtensionMethod.Message);
            }
		    return null;
		}