Doing virtual simulationary keyboard stuff, only for real

by Michael S. Kaplan, published on 2008/07/27 03:01 -04:00, original URI:

Reader Barney asks:


I've been reading your blog for a while and using all the good bits, but I have a problem I can't find the answer to.

I have created an on screen keyboard, and the user can enter some text that will be typed by the keyboard.

When parsing and typing the string to the target application (essentially a VB SendKeys replacement) I'm using VkKeyScan to determine how to send the key.  However, as you note in some earlier posts, this does not return dead keys.

How do I determine which dead key(s) I need to type to print a character (for example á on a Portuguese (Portugal) layout)?

Many thanks,

He is right, VkKeyScan/VkKeyScanEx aren't going to do the trick.

But there is a lot of other stuff missing from those functions, too -- it is best just ignored for any genuine need.

The only real, supported answer for code running in user mode is the solution that just asks the keyboard for all of the information and stores it for you to use as you need it....

This is code I have actually written twice in my life:

Now the first one is a bit more challenging to get to (I suppose it could be eventually puzzled out via Reflector?), but it is the code that supports the "test surface" in MSKLC that lets you test out the layout as you are developing it.

The latter's source, however, is right there in the series. It is written in C# but it is mainly Win32 code written in C# for easy conversion to other languages.

By storing the information on what the keystrokes do, you can simulate their effects later on....


This blog brought to you by(U+0c98, aka KANNADA LETTER GHA)

no comments

go to newer or older post, or back to index or month or day