截取关键presses即使在形式没有焦点形式、关键、焦点、presses

2023-09-04 00:12:08 作者:朕发疯起来自己都怕

我已经建立了一个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.