以编程方式检测屏幕阅读器

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.

昨天我正在安装Visual Studio 2010的RC,并且在安装程序运行时,我注意到树视图中出现了“检查”和“未检查”两个词。

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.

我根据此处找到的这段代码运行了一个小程序。 我开始使用在PInvoke.NET上找到的结构,但是它们过大了。 我不需要六页常量。

[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.

好吧,实际上,是的。 我进行了很多演示,有时只是一个人看着我的肩膀,因此我通过WinKey和PLUS热键运行Windows 7放大镜。 当Windows放大镜运行时,我正在运行屏幕阅读器,因为我正在运行辅助功能助手。

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

有趣的东西。 当应用程序正在关注并提供辅助功能时,我会喜欢它。

翻译自: https://www.hanselman.com/blog/programmatically-detecting-screen-readers

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值