Re: SetWindowsHookEx->Modding keyboard input
Basically, that is an initial keydown notification, and you send a b, and then when you callnexthook the window manager still interprets the data as an a, and then you get a keyup and you send a b anyways. You can fix this by sending the b only when it's a keydown, and not calling callnexthookex when it is a keydown you are replacing. I think.
Re: SetWindowsHookEx->Modding keyboard input
eh...i am still having a problem...now i am getting ba:
Code:
if (nCode == HC_ACTION)
{
if(wParam== WM_KEYDOWN)
{
KBDLLHOOKSTRUCT* kbh=(KBDLLHOOKSTRUCT*)lParam;
switch(kbh->vkCode)
{
case 0x41:
{
keybd_event(0x42,0,0,0);
return 0;
}
};
}
else
{
KBDLLHOOKSTRUCT* kbh=(KBDLLHOOKSTRUCT*)lParam;
switch(kbh->vkCode)
{
case 0x41:
{
return 0;
}
};
}
}
return CallNextHookEx(NULL, nCode, wParam, lParam);
Any idea why?
Re: SetWindowsHookEx->Modding keyboard input
It's possible that you can not do this with WH_KEYBOARD_LL hooks then, and that stopping the hook chain doesn't make the computer forget that it's there.
Re: SetWindowsHookEx->Modding keyboard input
Hmm...is there another way to hook the keyboard input then?I don't want to start injecting code, because that would be versino dependent, so any other possibilites, maybe something in ring 0?
Re: SetWindowsHookEx->Modding keyboard input
Quote:
Originally Posted by Quell
Hmm...is there another way to hook the keyboard input then?I don't want to start injecting code, because that would be versino dependent, so any other possibilites, maybe something in ring 0?
Did you try to simply replace the data you receive in the hook, and call ::CallNextHookEx() with the swapped key, instead of generating keystroke in the hook?
Cheers
Re: SetWindowsHookEx->Modding keyboard input
yep, does nothing
Code:
if (nCode == HC_ACTION)
{
if(wParam == WM_KEYDOWN)
{
KBDLLHOOKSTRUCT* kbh=(KBDLLHOOKSTRUCT*)lParam;
switch(kbh->vkCode)
{
case 0x41:
{
/*keybd_event(0x42,0,0,0);
return 0;*/
kbh->vkCode=0x42;
}
};
}
/*else
{
KBDLLHOOKSTRUCT* kbh=(KBDLLHOOKSTRUCT*)lParam;
switch(kbh->vkCode)
{
case 0x41:
{
return 0;
}
};
}*/
}
return CallNextHookEx(NULL, nCode, wParam, lParam);