Exemplo n.º 1
0
        public override IEnumerable <Element> GetElementsFromQuery(Query query)
        {
            var result     = new List <WinElement>();
            var candidates = new Queue <WinElement>();
            var targetPath = query.First(x => x.Name == "Path").Value.ToString();

            candidates.Enqueue(WinElement.GetRoot());
            while (candidates.Count > 0)
            {
                var candidate     = candidates.Dequeue();
                var candidatePath = candidate.Path;
                if (targetPath.StartsWith(candidatePath))
                {
                    if (targetPath.Equals(candidatePath))
                    {
                        if (candidate.TryQuery(query))
                        {
                            result.Add(candidate);
                        }
                    }
                    else
                    {
                        foreach (var child in candidate.Children)
                        {
                            candidates.Enqueue(child);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
 protected override bool UpdateViewport(WinElement winElement)
 {
     this.Viewport = Rectangle.Empty;
     if (winElement != null && winElement.MainWindow is WinElement target && target.ProcessId == this.ProcessId)
     {
         if (target.GetElement(x => x.Class == "Internet Explorer_Server" || x.Class == "NewTabWnd") is WinElement viewport)
         {
             this.Viewport = viewport.Bounds;
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 3
0
 protected override bool UpdateViewport(WinElement winElement)
 {
     this.Viewport = Rectangle.Empty;
     if (winElement != null && winElement.MainWindow is WinElement target && target.ProcessId == this.ProcessId)
     {
         if (target.GetElement(x => x.Class == "Chrome_RenderWidgetHostHWND") is WinElement viewport)
         {
             this.Viewport = viewport.Bounds;
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 4
0
 protected override bool UpdateViewport(WinElement winElement)
 {
     this.Viewport = Rectangle.Empty;
     if (winElement != null && winElement.MainWindow is WinElement mainWindow &&
         mainWindow.Class == "ApplicationFrameWindow" &&
         mainWindow.Children.FirstOrDefault(x => x.Type == "window" && x.Name == "Microsoft Edge" && x.Class == "Windows.UI.Core.CoreWindow") is WinElement target &&
         target.ProcessId == this.ProcessId)
     {
         if (target.GetElement(x => x.Class == "Internet Explorer_Server" || x.Class == "NewTabPage") is WinElement viewport)
         {
             this.Viewport = viewport.Bounds;
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 5
0
 protected abstract bool UpdateViewport(WinElement target);
Exemplo n.º 6
0
 public override Element GetElementFromPoint(int screenX, int screenY)
 {
     return(WinContext.Target = WinElement.GetFromPoint(screenX, screenY));
 }
Exemplo n.º 7
0
 private WinContext()
 {
     this.ProcessId = WinElement.GetRoot().ProcessId;
 }
Exemplo n.º 8
0
 public override Element GetElementFromFocus()
 {
     return(this.Target = WinElement.GetFromFocus());
 }