Tuesday, March 28, 2017

AutomationElement does not retrieve unvisible elements

Leave a Comment

I am trying to get all elements in my Skype program (including all chat tabs), but I get only the visible items.

This it the code:

var window = AutomationElement.RootElement.FindFirst(TreeScope.Subtree,                 new PropertyCondition(AutomationElement.ClassNameProperty, "tSkMainForm"));  if (window != null) {     var items = window.FindAll(TreeScope.Subtree, Condition.TrueCondition);     //DO SOME CODE... } 

The items property does not contain all unvisible items (for example, inner details of chat with someone, let's say, Dan). But if the chat with Dan is opened on my Skype, then the items property would contain also inner details of this chat with Dan. I want the items property to have the chat inner details even if the tab is not opened in my skype.

Why my code does not retrieve all data? How could I get all data (including all chat tabs even when they are not opened)?

1 Answers

Answers 1

iterating through all GridControl rows, use the IScrollProvider interface implementation of GridControlAutomationPeer

private void Button_Click_1(object sender, RoutedEventArgs e) {             var p = Process.GetProcessesByName(ProcName).FirstOrDefault(x => x != null);             if (p == null) {                 Console.WriteLine("proccess: {0} was not found", ProcName); return;             }             var root = AutomationElement.RootElement.FindChildByProcessId(p.Id);             AutomationElement devexGridAutomationElement = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, DevexGridAutomationId));             if (devexGridAutomationElement == null) {                 Console.WriteLine("No AutomationElement was found with id: {0}", DevexGridAutomationId);                 return;             }              var cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataItem);             var devexGridItems = devexGridAutomationElement.FindAll(TreeScope.Descendants, cond);             GridPattern gridPat = devexGridAutomationElement.GetCurrentPattern(GridPattern.Pattern) as GridPattern;             Console.WriteLine("number of elements in the grid: {0}", gridPat.Current.RowCount);         } 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment