禁用 .NET 应用程序中的辅助功能快捷方式?
这篇 msdn 文章 -- http://msdn.microsoft .com/en-us/library/bb219746(VS.85).aspx#Disabling_Accessibility_Shortcut_Keys - 为 C++ 程序员提供有关如何临时禁用 Windows 辅助功能快捷方式的信息(例如按住 Shift 8 秒,或快速连续按 Shift 超过 5 次)。
当然,在 C# 中有一些简单的方法可以做到这一点,但我找不到任何相关资源。 我在非全屏应用程序中使用 DirectInput。
我想要做的就是不要出现烦人的弹出窗口; 不过,我更喜欢一些不必破坏 Windows 设置的东西,以防万一应用程序以非正常方式关闭(我不希望在这些情况下永久更改用户的设置) 。
有什么想法吗?
This msdn article -- http://msdn.microsoft.com/en-us/library/bb219746(VS.85).aspx#Disabling_Accessibility_Shortcut_Keys -- provides information for C++ programmers on how to temporarily disable the windows shortcuts for accessibility (such as holding Shift for 8 seconds, or pressing Shift more than 5 times in quick succession).
Surely there's some easy way to do this in C#, but I can't find any resources on this. I'm using DirectInput in a non-fullscreen application.
All I want to do is not have the annoying popups come up; I'd prefer something that doesn't have to muck with the windows settings, though, just in case the application shuts down in a non-graceful manner (I'd prefer not to have the user's settings be permanently altered in those situations).
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
以防万一其他人需要这个,这里是转换后的 C# 代码,它最终可以工作:
请注意,我无法从 C++ 转换三个 IF 语句(这些语句已被注释掉)。 Microsoft 推荐这些,但我不知道如何让它们在 C# 中工作。 此外,我没有在结构上使用 sizeof() (而是手动为其大小创建变量),因为这样做需要不安全的代码,而且我不希望这是我的特定程序的要求。
Just in case anyone else needs this, here's the converted C# code, which at last does work:
Do note that I was unable to convert three of the IF statements from C++ (those are commented out). Microsoft recommends those, but I don't know a way to make them work in C#. Additionally, I'm not using sizeof() on the structs (instead manually creating variables for their size), because to do that would require unsafe code, and I don't want that to be a requirement for my particular program.
感谢各位在我的 XNA 游戏中完成了一些小工作,以防止粘滞键弹出。
这是完成的代码:
我在游戏开始时将参数设置为 false 并在游戏退出并将参数设置为 true 之前使用它:
据我所知,它运行得很好。
问候
Thanks guys with some minor finishing off that worked in my XNA game to prevent the sticky key popup.
Here is the finished code:
I use it at the start of the game with the parameter set to false and just before the game exits with the parameter set to true:
It works perfectly as far as I can tell.
Regards
您必须执行与您引用的链接中相同的操作。 SystemParametersInfo API 函数可以通过 P/Invoke 层调用,您可以在此处找到定义:
http://www.pinvoke.net/default.aspx/user32/SystemParametersInfo.html
You will have to do the same thing that is done in the link you reference. The SystemParametersInfo API function can be called through the P/Invoke layer and you can find the definition here:
http://www.pinvoke.net/default.aspx/user32/SystemParametersInfo.html
关于上面发布的 C# 代码的注意事项:
您可以通过与结构体的 flags 字段进行 AND 运算来转换这些问题行,如下所示:
if ((skOff.dwFlags & SKF_STICKYKEYSON) == 0)
您需要添加以下行:
私有常量 FKF_FILTERKEYSON = 0x00000001;
也在 const 定义下。
Note in relation to the C# code posted above:
You can convert those problem lines by AND-ing with the flags field of the struct like so:
if ((skOff.dwFlags & SKF_STICKYKEYSON) == 0)
You'll need to add the line:
private const uint FKF_FILTERKEYSON = 0x00000001;
under the const definitions as well.
你可能会看一下,C# 也在
这里找到了它
http://social. msdn.microsoft.com/Forums/en-US/csharplanguage/thread/47647b7e-b23f-4f80-9363-ffd5f11a2570
干杯
You may look this also C#
found it here
http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/47647b7e-b23f-4f80-9363-ffd5f11a2570
cheers