views:

58

answers:

1

I am writing my own on screen keyboard.

The only piece missing is the position of each key on the keyboard.

Windows allows you to get the keyboard layout: http://msdn.microsoft.com/en-us/library/ms929433.aspx

But how does one get the position of a key for a given layout?

+1  A: 

I do not think (am quite sure that) you cannot get (X, Y) coordinates of a key on a keyboard, given a language identifier. After all, this depends on the keyboard. When it comes to the typical layouts, I guess you have to obtain the data from some external source...

Andreas Rejbrand
So how do I know if the user is using QWERTY, AZERTY or other?
@user380719: In general, you cannot. Windows doesn't need to know the physical location of the keys on the keyboard. Also, you can connect as many keyboards as you like to the computer (via USB). Some may be QUERTY, and some may be AZERTY.
Andreas Rejbrand
But windows does know whether the input is QWERTY ar AZERTY.In fact, you can use a QWERTY keyboard and set it to AZERTY. When you press "Q", Windows gets "A".
@user380719: You might very well be right. I wonder how to obtain this information...
Andreas Rejbrand
I believe Andreas is right. I am pretty sure, the only knowledge that Windows has is what scan code to map to a keypress. I think display of the physical layout likely falls to dedicated programs like their OSK.exe
Philip T.
I don't think you can find out, just give the user the option, and change the layout according to what he selected. :)
pedro_cesar