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); }
private WinContext() { this.ProcessId = WinElement.GetRoot().ProcessId; }