| knowledge-database (beta) |
 |
Current group: comp.soft-sys.wxwindows
virtual key codes, scan codes and wxKeyEvent
|
|
 | | From: | David Norris | | Subject: | virtual key codes, scan codes and wxKeyEvent | | Date: | Sat, 22 Jan 2005 00:57:49 +0000 (UTC) |
|
|
 | Greetings,
I've got a wxWindows-based program that involves simulating keystrokes using the Windows API's SendInput() function. The user selects the key to be simulated by opening a "capture" window and simply pressing the desired key. The wxKeyEvent contains a "key code" and a "raw key code." It seems that event.GetRawKeyCode() on Windows just returns one of the Windows-defined virtual key codes. So far, so good.
When it comes time to simulate the keystroke, though, things get a bit tricky. Suppose we've captured the virtual key code for "Delete." The SendInput() function requires both a virtual key code and a scan code, so I use MapVirtualKey() to convert VK_DELETE into an appropriate scan code. But there are two Delete keys on the keyboard, and two separate scan codes! Windows doesn't really know which one to choose, so it arbitrarily picks one (in this case it happens to pick the scan code for the one on the numeric keypad). 99% of the time it doesn't matter, but there are a few programs that do actually differentiate between the two keys.
Of course this doesn't have anything to do with wxWindows. But my question is: how can I get access to the scan codes when I capture a keystroke, so that I can faithfully reproduce the key the user actually pressed? Will wxWindows let me "go over its head" and get the raw event data from Windows? Or can anyone suggest another creative solution to this problem?
Thanks, -- David Norris danorris@gmail.com
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
|
|
|
| | |
|
 |