Low Level keyboard hook c++

时间:2015-06-26 10:23:04

标签: c++ winapi keyboard-hook

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 个答案:

答案 0 :(得分:2)

  

有人可以解释如何在不使用keybd_event函数的情况下更改用户输入,但在操作系统解释之前更改密钥本身。

你做不到。您必须拒绝钥匙,然后使用getRandomUserkeybd_event()发布您自己的钥匙。请务必检查SendInput()字段是否启用了KBDLLHOOKSTRUCT::flagsLLKHF_INJECTED标记,这样您就不会拒绝自己的模拟密钥。

  

我尝试了一些MSG并更改了wparam,但它没有工作

LLKHF_LOWER_IL_INJECTED结构不与MSG挂钩一起使用。