Greetings,
I've implemented a low-level keyboard hook as described here. This works fine under WinXP. Problem is, under Windows 7 the left and right windows keys a开发者_开发百科re no longer intercepted.
Any suggestions as to how to recapture these keys under Windows 7 greatly appreciated!
Cheers,
Rony
I have built a library because normal hooking was not working for me in a number of cases, so I've built a c library to communicate with filter drivers under the hood to do the work of device input interception. Here's a sample of how to capture the Windows key using this library:
#include <iostream>
#include <interception.h>
#include "utils.h" // for process priority control
const InterceptionKeyStroke windows_key_down = {91, INTERCEPTION_KEY_E0 | INTERCEPTION_KEY_DOWN};
const InterceptionKeyStroke windows_key_up = {91, INTERCEPTION_KEY_E0 | INTERCEPTION_KEY_UP};
bool operator == (const InterceptionKeyStroke &left, const InterceptionKeyStroke &right)
{
return left.code == right.code && left.state == right.state;
}
int main()
{
using namespace std;
InterceptionContext context;
InterceptionDevice device;
InterceptionStroke stroke;
raise_process_priority();
context = interception_create_context();
interception_set_filter(context, interception_is_keyboard, INTERCEPTION_FILTER_KEY_ALL);
while(interception_receive(context, device = interception_wait(context), &stroke, 1) > 0)
{
InterceptionKeyStroke &keystroke = *(InterceptionKeyStroke *) &stroke;
if(keystroke == windows_key_down)
cout << "Windows Key Down" << endl;
if(keystroke == windows_key_up)
cout << "Windows Key Up" << endl;
interception_send(context, device, &stroke, 1);
}
interception_destroy_context(context);
return 0;
}
The sample captures the key and send it back to the operating system, but you can do other things instead.
You can check more docs at http://oblita.com/Interception.
Take a look at the Win Kernel SDK for Windows 7 and program a "driver" that do hook this too.
精彩评论