Friday, 23 August 2013

C++ RegisterHotKey without overriding existing functionality

C++ RegisterHotKey without overriding existing functionality

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);
}
}

No comments:

Post a Comment