How to detect if screen reader is running (JAWS)?
As I understand in .NET 4 we can use AutomationInteropProvider.ClientsAreListening
from System.Windows.Automation.Provider
namespace, but what if I have to do it for .NET 2.0?
I tried to inspect ClientsAreListening
source code, it calls external RawUiaClientsAreListening
method from UIAutomationCore.dll library.
Do you have any ideas how to implement JAWS detection in .NET 2.0?
Use the
SystemParametersInfo
function passing auiAction
ofSPI_GETSCREENREADER
.You will need to use P/Invoke for this, for example:
This is possibly better than using the
ClientsAreListening
property as this property appears to return true for any automation client, not just screen readers.Also see:
You should also listen for the
WM_SETTINGCHANGE
message to detect if a screen reader starts / stops running.Update (in response to BrendanMcK's comments):
Although this is never explicitly documented in as many words, looking at the description of the flag I think the purpose of this flag is relatively clear:
What this is saying is that applications set this flag whenever an application wishes the UI to behave as if a screen reader is running, regardless of whether or not that application is actually a screen reader or not.
Suitable things to do in response to this flag is to add text in order to "read" otherwise intuitive UI state to the user. If radical changes are needed to make your UI screen reader accessible then the chances are that your UI also isn't that intuitive to sigted users and could probably do with a re-think.