Descolada/UIAutomation

SelectionItem and SelectionItemPattern doesn't work as expected.

Closed this issue · 3 comments

Here is how to reproduce it:

  1. Download this file and open it in Excel. https://drive.google.com/file/d/1d_Qkm9wZWxhzP_-PMd0LBDCmgETpTDK3/view?usp=sharing

  2. Click on the Open Form Button.
    image

  3. It will open this form. Now keep this form open.
    image

  4. Now Run "UIATreeInspector.ahk"

  5. Select like below image for that particular UI.
    image

  6. Select any item from these two list and double click on the select()

  7. You will get an error like this.
    image

Let me know if I can explain any other things.

I am able to reproduce this with UIA_Interface, UIA v2, the Acc library, and also with Accessibility Insights. This means the problem is most likely in how Excel implements IAccessible/Acc (the old version of UIAutomation) for that particular window. Window spy reports the control name for the listbox as "F3 Server 0e3f00002" which is unusual as well, as it should be something like "Listbox1", so it's some kind of special implementation by Excel. It appears Element.LegacyIAccessiblePattern.DoDefaultAction() works IF the listbox is already selected, but it can't select multiple items in the second listbox. Element.ControlClick() seems to select single items as well, but selecting multiple items also did not work. I could select multiple items with

Send {Ctrl down}
Element.Click("left")
Send {Ctrl up}

but of course the elements need to be visible (that is, not scrolled out of view) for this to work.

I'm closing this because unfortunately there isn't a fix possible from this libraries side.

Element.Click("left") seems selecting the wrong item in the list.

Works fine here...

#Requires AutoHotkey v1 
#include <UIA_Interface>

UIA := UIA_Interface()
winTitle := "Sample UI to showcase UIA Select Issue ahk_exe EXCEL.exe"
WinActivate %winTitle%
WinWaitActive %winTitle%
winEl := UIA.ElementFromHandle(winTitle)
winEl.FindFirstByNameAndType("Badminton", "ListItem").Click("left")
Send {Ctrl down}
winEl.FindFirstByNameAndType("Football", "ListItem").Click("left")
Send {Ctrl up}
winEl.FindFirstByNameAndType("Male", "ListItem").Click("left")
ExitApp

ExcelTest