问题
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