0
votes

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 :)

2
Which ones have you found already? - payne
and a few on SO but they seem too complicated :/ - Ozzy
The MSDN example seems straightforward -- I can't see how to make it much simpler. Have you tried using that as a starting point? Or just compiling it to see how it works? - payne
I tried compiling it but it just shows an empty cmd box and disappears :/ - Ozzy

2 Answers

3
votes

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?

1
votes

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