public bool IsTopmost()
 {
     _windowPattern = _window?.GetCurrentPattern(UIA_PatternIds.UIA_WindowPatternId) as IUIAutomationWindowPattern;
     if (_windowPattern == null)
     {
         return(false);
     }
     return(_windowPattern.CurrentIsTopmost != 0);
 }
        protected override void Dispose(bool disposing)
        {
            if (Pattern != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(Pattern);
                this.Pattern = null;
            }

            base.Dispose(disposing);
        }
 private bool SetWindowVisualState(WindowVisualState state)
 {
     _windowPattern = _window?.GetCurrentPattern(UIA_PatternIds.UIA_WindowPatternId) as IUIAutomationWindowPattern;
     if (_windowPattern == null)
     {
         return(false);
     }
     _windowPattern.SetWindowVisualState(state);
     _windowPattern.WaitWithTimeoutTill(x => x.CurrentWindowVisualState == state);
     return(_windowPattern.CurrentWindowVisualState == state);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// <para>Sets/Resets the Pattern and its properties.</para>
        /// <para>Useful in this class for resetting the Pattern's properties after an action is performed on the Element.</para>
        /// </summary>
        private void Initialize(WindowElement element)
        {
            this._element = element;

            int counter = 0;

            do
            {
                try
                {
                    _WindowPattern = (IUIAutomationWindowPattern)element.IUIElement.GetCurrentPattern(UIA_PatternIds.UIA_WindowPatternId);
                }
                catch (COMException e) { }
                catch (InvalidOperationException ex) { }
                Thread.Sleep(10);
            } while (_WindowPattern == null && counter++ < 50);

            if (_WindowPattern == null)
            {
                throw new Exception($"Pattern is not available for Element where Name=[{_element.Name}] - AutomationId=[{_element.AutomationId}] - ClassName=[{_element.ClassName}].");
            }

            this.SetProperties();
        }
        public WindowPattern(A11yElement e, IUIAutomationWindowPattern p) : base(e, PatternType.UIA_WindowPatternId)
        {
            Pattern = p;

            PopulateProperties();
        }
 public static void xtMaximizeWindow(this IUIAutomationElement element)
 {
     _WindowPattern = (IUIAutomationWindowPattern)element.GetCurrentPattern(UIA_PatternIds.UIA_WindowPatternId);
     _WindowPattern.SetWindowVisualState(WindowVisualState.WindowVisualState_Maximized);
 }
Ejemplo n.º 7
0
 internal static WindowPattern Wrap(
     AutomationElement element,
     IUIAutomationWindowPattern windowPattern)
 {
     return(new WindowPattern(element: element, windowPattern: windowPattern));
 }
Ejemplo n.º 8
0
 WindowPattern(AutomationElement element, IUIAutomationWindowPattern windowPattern)
     : base(el: element)
 {
     this._windowPattern = windowPattern;
 }
 private WindowPattern(AutomationElement el, IUIAutomationWindowPattern pattern, bool cached)
     : base(el, cached)
 {
     Debug.Assert(pattern != null);
     this._pattern = pattern;
 }