截取关键presses即使在形式没有焦点 [英] intercepting keypresses even when the form does not have focus

查看:135
本文介绍了截取关键presses即使在形式没有焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个WinForms应用程序,它检查CTR + ALT + S和Ctrl + Alt + E键presses,使用通过覆盖ProcessCmdKey方法。这个伟大的工程,但如果屏幕亮起,然后熄灭的形式没有重点和关键presses不拦截。我怎样才能收到这些即使窗体不具有焦点?

I've built a winforms application which checks for CTR+ALT+S and CTRL+ALT+E keypresses, using by overriding the ProcessCmdKey method. This works great, but if the screensaver goes on and then goes off the form doesn't have focus and the keypresses aren't intercepted. How can I receive these even if the form does not have focus?

推荐答案

亚历山大·沃纳有一个的系统热键组件项目,在上封装了RegisterHotkey()API到用户控件,可以很容易的实现code项目。

Alexander Werner has a "System Hotkey Component" project over at Code Project that wraps the RegisterHotkey() API into a user control that's really easy to implement.

这篇关于截取关键presses即使在形式没有焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆