views:

55

answers:

1

My friend is learning Norwegian and i want to make a global hot key program which sends keys such as

æ
ø
å

My problem is that keybd_event function wont allow me to send those keys, i seem to be restricted to the virtual key codes is there another function that i could use or some trick to sending them?

+1  A: 

You have to use SendInput instead. keybd_event does not support sending such characters (except if they are already in the current codepage, like on Norwegian computers). A bit of sample code to send an å:

KEYBDINPUT kb={0};
INPUT Input={0};

// down
kb.wScan = 0x00c5;
kb.dwFlags = KEYEVENTF_UNICODE;
Input.type = INPUT_KEYBOARD;
Input.ki = kb;
::SendInput(1,&Input,sizeof(Input));

// up
kb.wScan = 0x00c5;
kb.dwFlags = KEYEVENTF_UNICODE|KEYEVENTF_KEYUP;
Input.type = INPUT_KEYBOARD;
Input.ki = kb;
::SendInput(1,&Input,sizeof(Input));

In case you didn't know: it is easy to install additional keyboard layouts on Windows and switch between them with a shortcut.

Lykke til!

wmeyer
Thanks! works perfectly, i tried this method once before but I put the wScan as 'æ' and it didn't work... i thought it would convert it to hex for me :P thanks again!
Ah, noticed if you say wScan = _T('æ'); or L'æ'; that works too, just don't have to figure out the hex code for it.