Sending keystrokes to the console
One of the ways Console Wrapper is currently lacking, is that it doesn’t have a full set of features that one would expect from a regular console. Some are being built in (such as command history), but TAB completion, Ctrl-C process kill etc are still missing. These could be solved (in theory) by directly passing advanced keystrokes through to the console process.
ConsoleWrapper currently communicates with the console process via input and output streams. These allow for sending and receiving of string data, but not specific keystrokes (such as Ctrl-C). Unfortunately I’m still working on exactly how I can pass a key to the console. Because it doesn’t run in its own window (in order to capture input/output streams and hide the real console from the user) normal WinAPI methods for sending keystrokes do not work, as they target a window handle. In fact the regular console may not even have a message queue. So for now I’m stuck experimenting with SendMessage and WM_KEYDOWN, WM_KEYUP, etc. Not a nice clean .NET solution as I would have liked!
This entry was posted on Sunday, June 15th, 2008 at 2:41 pm and is filed under Console Wrapper. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Tom is a 23 year-old software engineer currently based in Auckland, New Zealand. Click