change a keystroke passing a hook(c/c++)

别等时光非礼了梦想. 提交于 2019-12-08 01:35:59

问题


is it possible to edit a keystroke using a winapi keyboard hook? well, not neccesary a keyboard hook but something like it..

i wanna do something like this:

user presses key 'A'

my function adds 1 to the virtual keycode (just an example)

the 'A' becomes an 'B'

and the 'B' is sent to the destination application

thanks!


回答1:


First, you need a Keyboardhook. You install a filter and the filter function receives the virtual-key code and the state of the keyboard at the time of the keyboard hook. Then you can change the virtual-key code.

Additional Links:

http://msdn.microsoft.com/en-us/library/ms644990(VS.85).aspx

http://msdn.microsoft.com/en-us/library/ms644984(VS.85).aspx




回答2:


I think you can do it by eating up the keystroke entered by user by applying keyboard hook. and generating key_event of the character you want.




回答3:


You can't change the virtual key value in the KBDLLHOOKSTRUCT directly. Instead, return 1 in the hook function after you sendmessage with your modified virtual key value.



来源:https://stackoverflow.com/questions/1630315/change-a-keystroke-passing-a-hookc-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!