0

I'm working on a VBA program to help automate a task using UI Automation, but I've run into an issue where the window of the program I'm trying to control does not show up as a child of the Root Element (desktop).

It's my understanding that all elements are children/descendants of the desktop element, so why it's not showing up is puzzling. Here is the code I'm using to see all the children of the Desktop element:

Sub test_get_windows()
    Dim oAutomation As New CUIAutomation
    Dim oDesktop As UIAutomationClient.IUIAutomationElement
    Dim oCondition As UIAutomationClient.IUIAutomationCondition
    Dim oChilds As UIAutomationClient.IUIAutomationElementArray
    Dim i As Integer
    
    Set oDesktop = oAutomation.GetRootElement
    Set oCondition = oAutomation.CreateTrueCondition
    Set oChilds = oDesktop.FindAll(TreeScope_Children, oCondition)

    For i = 0 To oChilds.Length - 1
        Debug.Print oChilds.GetElement(i).CurrentName
    Next i
End Sub

I see everything except the window I'm trying to interact with. I tried the code on another computer, and I'm able to see the window.

Computer where it doesn't work:

Computer where it does work:

The AcSELerator Quickset window does not show up on the first computer but it does on the second, so I don't think it's a problem with the application. Both computers have the same version installed and are running Windows 10 Enterprise. Any ideas on what the issue could be or any troubleshooting steps I can try?

AHeyne
  • 3,377
  • 2
  • 11
  • 16
Bob
  • 1
  • 1
    Are both computers logged in with account that has the same level of user privileges? From googling similar issues, it seems that the version of .NET installed matters - [Example](https://stackoverflow.com/questions/11403720/windows-ui-automation-api-not-finding-child-elements-when-run-on-server) – Raymond Wu Jul 19 '21 at 01:07
  • Both computers have .NET 4.8 installed and are logged into non-admin accounts. I tried other applications, and I'm able to find their windows. The issue oddly seems to only affect this one application. – Bob Jul 19 '21 at 23:14

1 Answers1

0

The window doesn't have to be minimized. Try veryfyng that. That's what was happening to me. Similar case and Similar routine.

David G
  • 1
  • 1