How can I make my C# application the default ‘Print Screen’ handler in Windows?
I wrote a screen capturing utility and I want to, ideally, have it replace the default print-screen handler, or otherwise have a unique key combination that would trigger it.
I know how to do it in C++ using global hooks, etc., but it’s not clear to me how this can be done in .Net. Also, if there’s a way of doing it without using a memory resident application that would be super.
As long as you are using a WM_KEYBOARD_LL hook to capture the PrintScreen key, there is no reason you can’t do this in C#. It’s one of the few global hooks that can be used in managed code because it doesn’t require a DLL to be injected into every target process. Instead the context will switch back to the originating application for processing.
Adam’s blog has a great post on how to setup such a hook in C#: http://www.seesharpdot.net/?tag=wh_keyboard_ll