问题
I have been trying to capture the keys pressed outside of my winform, but obviously a KeyPress event won't work.
I haven't been able to get any closer than the KeyPress event, which only works on the form level, as specified
I suspect that I will have to do the
[DllImportAttribute("user32.dll")]
, but I have little to no experience with that.
回答1:
Being able to capture key presses anywhere requires using Hooks.
There is a library on CodePlex which simplifies implementing Application and Global Mouse and Keyboard Hooks for C# users.
来源:https://stackoverflow.com/questions/19171081/how-can-i-capture-a-key-press-outside-of-the-form