Introducing sharphook

While working on a project of mines, I realized I needed better control on keyboard input, especially I needed to catch input from all applications (not only focused one). Furthermore I was particularly interested in printable characters.


C# and .NET in general don’t make the task easy out of the box, but of course that was pretty straight with the old good Win32 APIs. Googling for some code wasn’t really helpful so I decided to go and take some time to make my own attempt.

With patience and our friend “Interop”, I created this small library which seems to be doing its job pretty well. Basically it installs a keyboard hook to intercept keyboard events and translate them to KeyDown, KeyPress, KeyUp events you’re used to in your .NET forms applications.

Just install the hook, register for the event you’re interested in and you’re ready to go! Just be sure to uninstall the hook to tidy up the room after use.

Source code and usage example included:

sharphook 0.0.1 (943 downloads)

Leave a Reply

Your email address will not be published. Required fields are marked *