
Low-level keyboard
Posted Sunday, 5 July, 2009 - 13:07 by Vahokif inI've been writing a 3D browser using OpenTK and Awesomium. Everything works great, except the function used to simulate keyboard events: void injectKeyboardEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam). I tried using SetWindowsHookEx with WH_GETMESSAGE to catch keyboard messages to GameWindow and pass them on, but all I got are CHAR messages and bogus results. What would be the best way to send GameWindow keyboard events to the browser?


Comments
Re: Low-level keyboard
WM_KEYDOWN/WM_KEYUP messages are intercepted by the IInputDriver before they reach GameWindow, so this approach probably won't work. Try installing a global WH_KEYBOARD_LL hook.
Re: Low-level keyboard
I'd prefer to write most of the app in C# which means I can't use global hooks, and I'd like to capture some messages that KEYBOARD_LL doesn't. Also, I need the HWND of the GameWindow. Can I modify OpenTK's keyboard input somehow so I have access to the raw messages?
Re: Low-level keyboard
Fortunately, there may be a simpler method to implement this functionality: hook GameWindow.KeyDown/KeyUp and synthesize WM_KEYDOWN/WM_KEYUP events for the browser via PostMessage.