When I register a hot key in C++ (the PrtScn key in this case), I noticed that the original functionality is lost. The key does not capture an image of the screen any more. IS there a way to register the hot key without breaking its existing bindings?
The Problem Context: I am trying to create an application to help our testing team automate their task of taking screenshots. When the user clicks PrtScn / Alt+PrtScn keys, I want to run a small application that picks the image on the clipboard and pushes it into a document. Most of this application is in Java, but I had to come to C++ for registering a hot key.
Thanks for your help!!
This is the code I used to register the hot key:
RegisterHotKey(NULL, 1, MOD_ALT | MOD_NOREPEAT, VK_SNAPSHOT);
RegisterHotKey(NULL, 2, MOD_NOREPEAT, VK_SNAPSHOT);
while (GetMessage(&msg, NULL, 0, 0) != 0)
{
if (msg.message == WM_HOTKEY)
{
WinExec(" The Java Application ", SW_SHOWNORMAL);
}
}
I don't think there's any documented way to trigger the OS's Print Screen functionality programmatically. I do have a few ideas you could try:
SendInput()
to resend the key press (this is admittedly a bit kludgy), orSetClipboardViewer()
etc.To me the last idea seems the best - you'll get notified when the clipboard contents change and then it's easy to see if the format on the clipboard is an image or not.