Scott Hanselman

Programmatically Detecting Screen Readers

March 25, 2010 Comment on this post [4] Posted in Programming | Windows Client
Sponsored By

Tree View

I was installing the RC of Visual Studio 2010 yesterday and while the setup program ran I noticed the words CHECKED and UNCHECKED appearing in the Tree View.

I was thinking I'd found some cool bug, like I was peering into some background world where checkboxes announce their state with text or something. I dunno, it was late, don't judge! ;)

I asked a few people and someone said to to see if I was running a Screen Reader. Screen Readers are what the visually impaired use to find their way around interfaces. It's no at bug at all, it's helping me.

I ran a little program based on this chunk of code found here. I started using the structures found at PInvoke.NET but they were overkill. I didn't need six pages of constants.

[DllImport("user32.dll")]
static extern bool SystemParametersInfo(int iAction, int iParam, out bool bActive, int iUpdate);

public static bool IsScreenReaderActive()
{
int iAction = 70; // SPI_GETSCREENREADER constant;
int iParam = 0;
int iUpdate = 0;
bool bActive = false;
bool bReturn = SystemParametersInfo(iAction, iParam, out bActive, iUpdate);
return bReturn && bActive;
}

static void Main(string[] args)
{
bool retVal = IsScreenReaderActive();
}

Scandalously, the result was true. What? I am running a screen reader? Um, no.

Well, actually, yes. I give lots of presentations, sometimes just to one person looking over my shoulder so I run the Windows 7 Magnifier via the WinKey and PLUS hotkey. When the Windows Magnifier is running, I'm running a Screen Reader in that I'm running an accessibility assistant.

Interesting stuff. I like it when applications are paying attention and helping with accessibility.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
March 25, 2010 4:47
If you're interested in playing with screen readers a bit more, install a copy of NVDA (free) and set yourself the challenge of browsing the web / writing emails with it for a few hours. :) It's a fun little exercise that every software developer should try at least once.

I spent a few hours yesterday with my secondary monitor turned off and NVDA running. If anything got too hard for me to navigate (bad website, or just me as the screen reader novice) I could always drag the flick the window back onto my primary monitor with Win+Left Arrow.
March 25, 2010 19:18
I would take Tatham's comment a step further. All software developer who are working on projects that will be released to "customers" should run their applications via the different accessibility assistant (especially screen readers) prior to release [Ideally this should be a specific QA task]

While regulations differ geographically, a program that does not meet the ADA [Americans with Disabilities Act] may not be purchased or required in environments that utilize certain government funding.
March 25, 2010 21:55
While you're on the subject of shortcuts, I saw your presentation on MIX and I like how you found you way around the keyboard...
I've asked quite a few people about this (in vain), if they can tell me the shortcut or the command for the: "Undo close Windows Explorer".
It's possible to close the window of a Windows Explorer at some path, and then "UNDO THE CLOSE" i.e. an explorer window opens up at the same location. The only way to access this functionality is though using the 'Speech Recognition' system. I was unaware of the command, until I got to 'train' the system ... had to check out if the voice commands actually work under Win7... they don't.

But there you go... I was unable to replicate this command without the 'voice command'. So... a feedback on this would be most welcome.

THX
June 17, 2010 15:03
HttpCachePolicy would be nice if it would work :)

But never the less, I get a hit on the server side for each and every request.
My other data service is based on a Linq-to-sql and I can see that it reaches the database everytime, even with those caching settings when the request starts.

However, it would be interesting how we can define SqlCachdeDependency and the server to get returning 304-not modified results!

Any advices/examples are welcome!

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.