Low-level Keyhook

我与影子孤独终老i 提交于 2019-12-13 00:52:56

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!