问题
I would like to run a low-level keyhook on a seperate thread in C# to detect for certain hotkeys. How would I do this?
回答1:
If you need this keyboard hook only to detect hot keys then you should not use a hook. Windows supports hot keys with the RegisterHotKey() API function. Check my code sample in this thread to see how to use it. There's a C# sample further down the page.
回答2:
You could use this library :
http://www.codeproject.com/KB/system/globalsystemhook.aspx
回答3:
You can to use DirectX. Add a reference to Microsoft.DirectX.DirectInput (after you've installed directX on your machine. Here is the SDK.)
Create an instance of the device class:
keyboard = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Keyboard);
And you can now listen to the keyboard.
来源:https://stackoverflow.com/questions/2191779/low-level-keyhook