AutomationElement can't find row cell values (but UISpy does)

1k Views Asked by At

I'm trying to get data from a window that has 3 lists (SysListView32). I do the same on the three of them, both UISpy and Inspect DO see rows and cells in the three of them, but when in code two of them works perfect (Caption="List2" and Caption="List3"), but the third contains ONLY white empty strings.

If I try:

IntPtr PrizeListHandle = Win32Utils.FindWindowByCaption(Lobby, "List1");
IUIAutomationElement dataGridPrizes = autom.ElementFromHandle(PrizeListHandle);
IUIAutomationGridPattern gridPrizes = dataGridPrizes.GetCurrentPattern(10006);

string linea = gridPrizes.GetItem(0, 0).CurrentName;

linea turns to be and empty string, gridPrizes has 17 rows, 3 columns, all cells are empty strings.

If I try:

IntPtr PrizeListHandle = Win32Utils.FindWindowByCaption(Lobby, "List1");
IUIAutomationElement dataGridPrizes = autom.ElementFromHandle(PrizeListHandle);
int propIdClassName = 30004; // UIA_ClassNamePropertyId;
IUIAutomationPropertyCondition conditionListItem = (IUIAutomationPropertyCondition)autom.CreatePropertyCondition(propIdClassName, "list item");
IUIAutomationElementArray children = dataGridPrizes.FindAll(interop.UIAutomationCore.TreeScope.TreeScope_Children, conditionListItem);

int i = children.Length;

i is 0. Why?

It's important to note that when using UISpy it finds EVERYTHING. Also, I have tried both managed an unmanaged version on Automation, with same exact results.

I'm using Windows Server 2008 R2.

Here's a screenshot: enter image description here

Thank you in advance

1

There are 1 best solutions below

0
On

You need use ScrollItemPattern.ScrollIntoView() bring into view.

var pattern = (ScrollItemPattern)aeDataGridCell
    .GetCurrentPattern(ScrollItemPatternIdentifiers.Pattern);
pattern.ScrollIntoView();