Thread: Win32 Hooks
View Single Post
  #7   Spotlight this post!  
Unread 29-04-2009, 19:26
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: Win32 Hooks

Quote:
Originally Posted by RyanCahoon View Post
You should be able to do this by modifying the vkCode in the lParam struct before calling CallNextHookEx. This function passes on the key on to the next handler in the hook chain, so passing a modified lParam will mean that all handlers that were registered before your (including the default windows handler) will see the modified value. At least that's how it works in theory.
This was the first thing I tried (with no success). However with the help of some other forums, I have a working solution. After detecting a desired input, I use SendInput() combined with INPUT structures to send my desired inputs. I then return a negative value instead of passing the message along the hook chain. The only thing is that I had to come up with a way so the same inputs being sent using SendInput() weren't processed by the hook, creating a recursive loop. I did this by setting a flag in the extra info of the input, and neglecting any input that came into the hook using that flag.
__________________

Last edited by slavik262 : 29-04-2009 at 19:38.