Not sure if this is the right board but it is in c...
I've got a console program written in c which receives key presses and
gets a Windows Virtual key code. I am trying to convert it to the exact
ascii value the user has typed. so if shift is down it should be a
capital otherwise lower case etc.
I started with this:
void printKey(int key)
{
printf("Key: %c\n", key);
}
and I got all upper case (not really suprising) so then after a bit of
research and grafting I came up with this:
int vk2ascii(unsigned int vk, int *s)
{
int scan;
unsigned char state[256];
HKL layout=GetKeyboardLayout(0);
if(!GetKeyboardState(&state))
return 0;
scan=MapVirtualKeyEx(vk, 0, layout);
return (ToAsciiEx(vk, scan, state, s, 0, layout)>0);
}
s should now contain the correct ascii value and so if passed to the
printKey function I thought I would get the right character but instead
everything just seems to be lowercase!
Does anyone have any ideas or can anyone point out where I'm being
dumb!!
Thanks for readin',
Gareth Williams