Low Level keyboard hook c++

795 views Asked by At

I tried to create an application in c++ that sets a low level keyboard hook and each time the user presses a key it will write a char of a string I made.

Can someone explain how can I change the user input without using the keybd_event function but changing the key itself before the OS interprets it.

I tried something with ths MSG and changing the wparam but it didn't work. If someone can show me a code example it will be better

1

There are 1 answers

0
Remy Lebeau On

Can someone explain how can I change the user input without using the keybd_event function but changing the key itself before the OS interprets it.

You cannot. You have to reject the key inyour hook and then post your own key using keybd_event() or SendInput(). And be sure to check if the KBDLLHOOKSTRUCT::flags field has the LLKHF_INJECTED or LLKHF_LOWER_IL_INJECTED flag enabled so you don't reject your own simulated keys.

I tried something with ths MSG and changing the wparam but it didn't work

The MSG structure is not used with a WH_KEYBOARD_LL hook.