如何在表格之外捕获按键? [英] How can I capture a key press, outside of the form?
本文介绍了如何在表格之外捕获按键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直试图捕获在Winform外部按下的键,但是显然KeyPress事件不起作用.
I have been trying to capture the keys pressed outside of my winform, but obviously a KeyPress event won't work.
我没有比KeyPress事件更近的地方,该事件仅在指定的表单级别起作用
I haven't been able to get any closer than the KeyPress event, which only works on the form level, as specified
我怀疑我将不得不做
[DllImportAttribute("user32.dll")]
[DllImportAttribute("user32.dll")]
,但是我对此几乎没有经验.
, but I have little to no experience with that.
推荐答案
Being able to capture key presses anywhere requires using Hooks.
CodePlex上有一个库,可为C#用户简化实现应用程序和全局鼠标和键盘挂钩.
There is a library on CodePlex which simplifies implementing Application and Global Mouse and Keyboard Hooks for C# users.
这篇关于如何在表格之外捕获按键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文