2

MSAA (Microsoft Active Accessibility) allows dynamic annotation wherein certain accessibility properties of controls can be set without having to re-implement MSAA interfaces. Specifically server annotation (which is a type of dynamic annotation) can be used to set properties of a control whose IAccessible interface we have.

How can similar thing be achieved using UI Automation? (UI Automation is the successor of MSAA but has different way of doing things.)

I have an MFC application with a list control containing 2 columns (ColA, and colB) and several groups. Each group has several items. Items always have data in colA, but for colB they may not have data. Microsoft accessibility insights shows error for these cases when colB is empty (item 3 in image). Error: "The name property of a focusable element must not be null".

MFC Dialog with list control

Using MSAA Server annotation (which is a kind of dynamic annotation) I can obtain the colB of every item and either set name property, or make it non focusable (both of which will remove the error). The problem is that this sub item (colB data) of a list item isn't exposed by MSAA. It is however exposed by UI Automation.

This means for the item I am able to get IUIAutomationElement interface, but not IAccessible interface.

Following image shows hierarchy shown by AccExplorer32.exe tool. This tool uses IAccessible interface (MSAA).

AccExplorer32.exe hierarchy

Following image shows hierarchy shown by Accessibility insights. This tool uses mainly IUIAutomationElement interface (MS UI Automation).

Accessibility insights tool

We can see that colB is not exposed separately in the hierarchy shown by AccExplorer32, but it is exposed in hierarchy shown by Accessibility insights.

Thus for the item I am able to get IUIAutomationElement interface, but not IAccessible interface. Server annotation as it is documented by MS requires IAccessible. According to MS dynamic annotation is supported by both MSAA, and MS UI Automation (see this). consequently server annotation too should be supported.

developers can use the Dynamic Annotation API to annotate Microsoft UI Automation properties as well as Microsoft Active Accessibility properties

Is there a way to use server annotation like dynamic annotation in UI Automation?

I have already tried the following.

  1. Use QueryInterface on the IUIAutomationElement of the sub item to obtain ILegacyIAccessibleProvider (from that I could have obtained IAccessible via GetIAccessible() method). However QueryInterface() fails indicating there is no such interface.
  2. Explored using UI Automation proxies (see this). These are used to augment existing servers with new properties and patterns. They are not used for setting values of existing properties.

Source code: https://github.com/lihas/WindowsAccessibilitySamples/tree/master/02MFCListControlAccessibility

Sahil Singh
  • 3,352
  • 39
  • 62
  • Difficult to say w/o a reproducing code/app. Microsoft accessibility insights is pretty new, has some issues, and IMHO is not super practical. Have you tried using inspect https://learn.microsoft.com/en-us/windows/win32/winauto/inspect-objects? – Simon Mourier Jan 24 '22 at 17:11
  • 1
    [How do I create a disabled checkbox for a listview item?](https://devblogs.microsoft.com/oldnewthing/20180524-00/?p=98825) has a couple of helpful links on the topic. – IInspectable Jan 24 '22 at 20:38
  • @SimonMourier It isn't about the tool but about using something like Server Annotation (which is an MSAA concept) with MS UI automation API. – Sahil Singh Jan 24 '22 at 21:39
  • @IInspectable The article explains from MSAA point of view. My list control doesn't support MSAA as well as it supports MS UI Automation. So I am unable to use MSAA. I need an answer which is for MS UI Automation. – Sahil Singh Jan 24 '22 at 21:41
  • 1
    It isn't about the tool but about understanding what you are trying to do – Simon Mourier Jan 24 '22 at 21:45

0 Answers0