I am trying my best to simulate keyboard input to get å and Å on windows mobile.
Unfortunately WM6 does not support KEYEVENTF_UNICODE and so my challenge begins.
I already tried SendInput, keybd_event, PostMessage, SendMessage and PostKeybdMessage. None of my tries worked. The problem is that most of the APIs only accept VK_ values and there is no VK_ value for the above chars. Using PostKeybdMessage to create æ and ø works fine, but not for å.
Here is the most working code:
// http://symbolcodes.tlt.psu.edu/accents/codealt.html
BOOL PostRawVKey( UINT vKey, UINT flag )
{
KEY_STATE_FLAGS kstate[1];
UINT charbuff[1];
BOOL bReturn = FALSE;
HWND hwnd = (HWND)-1;
switch (flag)
{
case VK_SHIFT:
kstate [0] = KeyShiftAnyShiftFlag;
break;
case VK_CONTROL:
kstate [0] = KeyShiftAnyCtrlFlag;
break;
case VK_MENU://ALT
kstate [0] = KeyShiftAnyAltFlag;
break;
case KeyShiftDeadFlag:
kstate[0] = KeyShiftDeadFlag;
default:
kstate [0] = KeyStateDownFlag;
break;
}
switch (vKey)
{
case VK_RETURN:
charbuff [0] = 0x0D;
break;
case VK_TAB:
charbuff [0] = 0x09;
break;
case VK_UP:
charbuff [0] = 0x26;
break;
case VK_DOWN:
charbuff [0] = 0x28;
break;
default:
charbuff [0] = vKey;
break;
}
if(PostKeybdMessage( hwnd, vKey, kstate[0], 1, &kstate[0], &charbuff[0]) )
{
bReturn = TRUE;
// keybd_event(0,0,m_dwUserDefinedKeySound,0);
}
return bReturn;
}
...
PostRawVKey(L'ä', 0);
PostRawVKey(L'æ', 0); // æ=0230 Æ=0198
PostRawVKey(L'°', KeyShiftDeadFlag);
PostRawVKey(L'a', 0);
PostRawVKey(L'ø', 0); // ø=0248 Ø=0216
PostRawVKey(L'å', 0); // å=0229 or 134, Å=0197 //not OK
...
and that is the result showing without any å:
I also tried using keybd_event and simulate Alt+134, no success.
Looking at the keyboard messages that are issued when you press the symbol on the soft keyboard, I see:
msg wParam lParam
KeyDown VK_CLEAR 0x00000001
CHAR å 0xe5 0x00000001
KeyUp VK_CLEAR 0xc0000001
and so I also tried
SendMessage(hwnd, WM_KEYDOWN, VK_CLEAR, 0x00000001);
SendMessage(hwnd, WM_CHAR, 0x000000e5, 0x00000001);
SendMessage(hwnd, WM_KEYUP, VK_CLEAR, 0xc0000001);
Can anyone provide a working example code (c/c++)?
As the Microsoft Keyboard can issue the å, how can I do it?
Background is a keyboard remapper that remaps some keys to danish chars.
User contributions licensed under CC BY-SA 3.0