-2

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

MichaelCMS
  • 4,703
  • 2
  • 23
  • 29
Yonatan Kreiner
  • 105
  • 1
  • 1
  • 10
  • 2
    Have you seen [this](https://msdn.microsoft.com/en-us/library/windows/desktop/ms644990%28v=vs.85%29.aspx#WH_KEYBOARD_LL) already ? – Blacktempel Jun 26 '15 at 10:40
  • yes I leared how to install the hook with that and I read everything in MSDN about setwindowshookex, wh_keybored_LL, keybd_event and MSG but didnt get my answer anywhere – Yonatan Kreiner Jun 26 '15 at 12:35

1 Answers1

2

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.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770