如何发送使用SendInput斯堪的纳维亚字母 [英] How to send scandinavian letters using SendInput

查看:357
本文介绍了如何发送使用SendInput斯堪的纳维亚字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个虚拟键盘,使用SendInput方法这样它模拟键盘:

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));
        }



但我不能找到斯堪的纳维亚字母A,O和A从键 - 枚举。我如何发送使用SendInput方法这些信吗?

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

推荐答案

您可以通过发送Unicode字符 KEYEVENTF_UNICODE

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();

这是比你使用的解决方案,更便携 OEM3 等,其已分配的角色将根据对您的应用程序正在执行平台的文化而有所不同。

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.

(P的休息/ Invoke的签名可以在找到我的其他回答。)

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

这篇关于如何发送使用SendInput斯堪的纳维亚字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆