Beispiel #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);
        }
Beispiel #2
0
 protected override bool UpdateViewport(WinElement winElement)
 {
     this.Viewport = default(Rect);
     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);
 }
 protected override bool UpdateViewport(WinElement winElement)
 {
     this.Viewport = default(Rect);
     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);
 }
Beispiel #4
0
 protected override bool UpdateViewport(WinElement winElement)
 {
     this.Viewport = default(Rect);
     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);
 }
Beispiel #5
0
 public override Element GetElementFromPoint(int screenX, int screenY)
 {
     return(WinContext.Target = WinElement.GetFromPoint(screenX, screenY));
 }
Beispiel #6
0
 private WinContext()
 {
     this.ProcessId = WinElement.GetRoot().ProcessId;
 }
Beispiel #7
0
 protected abstract bool UpdateViewport(WinElement target);