문제

I'm trying to create a virtual keyboard, which simulates keyboard using the SendInput method like this:

        public static void SendKeyDown(System.Windows.Forms.Keys key)
        {
            INPUT k = new INPUT();
            k.type = (int)InputType.INPUT_KEYBOARD;
            k.ki.wVk = (short)key;
            k.ki.dwFlags = (int)KEYEVENTF.KEYDOWN;
            k.ki.dwExtraInfo = GetMessageExtraInfo();

            SendInput(1, new INPUT[] { k }, Marshal.SizeOf(k));
        }

But I cannot find the scandinavian letters Ä,Ö and Å from the Keys -enumeration. How can I send these letters using the SendInput method?

도움이 되었습니까?

해결책

You can send Unicode characters using KEYEVENTF_UNICODE.

k.type = (int)InputType.INPUT_KEYBOARD;
k.ki.wScan = 'ö';
k.ki.wVk = 0;
k.ki.dwFlags = (int)KEYEVENTF.UNICODE | (int)KEYEVENTF.KEYDOWN;
k.ki.dwExtraInfo = GetMessageExtraInfo();

This is more portable than your solution of using Oem3 et al, whose assigned character would vary according to the culture of the platform on which your application is executing.

(Rest of P/Invoke signatures can be found in my other answer.)

다른 팁

Found solution myself:

Oem3 = ö, Oem7 = ä, Oem6 = å

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top