C# very simple keyboard hook

纵饮孤独 提交于 2021-02-08 11:47:43

问题


im trying to create a custom macro program in C# and I want to know how I can create a low level keyboard hook. I have looked around and have found some but i do not understand how they work or how i can customise it :/

can anyone show me how I can create a keyboard hook that basically does:

once any key is pressed, the int keycode is set to a method (i think the VK code is what i need?)

the exampels i find online seem too complicated for that :/

Thanks :)


回答1:


A Simple C# Global Low Level Keyboard Hook on CodeProject seems about right. It was the second hit on Google when I searched for 'keyboard hook' and the first when I searched for your exact title. Have you tried it?




回答2:


I wrote a RAW INPUT example on code project here, it may be helpful as a starting point.



来源:https://stackoverflow.com/questions/4928169/c-sharp-very-simple-keyboard-hook

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