1

I'm looking for a way to force a winforms controls which already has focus to be (re)announced by the screen reader.

The situation is that I have a manually painted area which the user is able to navigate around using the arrow keys, but since it's only a single control the focus is always the same so the screen reader only announces the control on the initial focus.

I have tried Focus()ing (and Select()ing) on a second control then immediately Focus()ing back, but this doesn't trigger the screen reader. The only way I've managed to get that working is to get the second control to wait 100ms then refocus back from a background thread, but then the second control is announced to the user, and there's a minefield of edge cases and race conditions.

It looks like UIA LiveRegions is the solution for this for .NET 4.7+, but I'm stuck on 4.6.

Any ideas how I can force the screen reader to re-announce the control under focus?

Taran
  • 12,822
  • 3
  • 43
  • 47
  • 1
    Since `RaiseAutomationNotification` and `RaiseLiveRegionChanged` are both part of .Net FW 4.8, if you cannot update, you could try to use the [AccessibleObject.Navigate()](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.accessibleobject.navigate) Method and, if not enough or unreliable, override both `GetChild()` and `Navigate()` in a custom `AccessibleObject`, as shown in the example there. Or modify your control to contain accessible elements instead of graphics. – Jimi Jun 25 '20 at 11:21
  • 1
    Instead of limiting yourself to the capabilities of .Net UIAutomation classes, consider using the native [UI Automation](https://learn.microsoft.com/en-us/windows/win32/winauto/entry-uiauto-win32) COM interface. See [this answer](https://stackoverflow.com/a/32786268/2592875) as an introduction to using the native API. – TnTinMn Jun 25 '20 at 12:52
  • Thank you both, I went down the AccessibleObject path in the end using Navigate() and NotifyClients() to achieve the goal. Feel free to write your comment as an answer and I'll accept it. – Taran Jul 06 '20 at 09:09

0 Answers0