设置OnKeyPress事件以进行应用 [英] Set OnKeyPress Event for Application

查看:58
本文介绍了设置OnKeyPress事件以进行应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早安,

我的应用程序的OnKeyPress事件运行正常,但是当我的应用程序窗口失去焦点时,此事件不再起作用.

无论焦点在哪里,是否都可以使我的应用程序保持onKeyPress事件正常运行?

谢谢,感谢您的帮助.

Good Day,

The OnKeyPress event for my application is working OK but when my application window lost the focus, this event doesn''t work anymore.

Is there anyway to keep onKeyPress event for my application working regardless where the focus is?

Thanks and your help is appreciated.

推荐答案

如果应用程序失去了焦点,通常不会得到按键事件.这是标准的Windows行为.如果仍然要处理键盘事件,请看一下本文:
在C#中处理全局鼠标和键盘挂钩 [
If your application lost the focus, you usually don''t get the key press events. That is standard windows behaviour. If you want to process keyboard events nontheless, have a look at this article:
Processing Global Mouse and Keyboard Hooks in C#[^]


这篇关于设置OnKeyPress事件以进行应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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