使用SendInput发送Unicode字符超出U + FFFF [英] Using SendInput to send unicode characters beyond U+FFFF

查看:688
本文介绍了使用SendInput发送Unicode字符超出U + FFFF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个类似于在Windows 8中我没有问题,将大部分我需要使用Win32的SendInput字符的屏幕键盘。

I'm writing an onscreen keyboard similar to the one in Windows 8. I have no problem sending most of the characters I need using Win32's SendInput.

问题是当它涉及到新的Windows 8绘文字的。他们开始U + 1F600使用的Segoe UI符号字体的。

The problem is when it comes to the new Windows 8 Emoji's. They start at U+1F600 using the Segoe UI Symbol font.

在Windows 8屏幕键盘我得到以下输出所有的表情符号字形。使用间谍++。

Using Spy++ on the Windows 8 onscreen keyboard I get the following output for all Emoji glyphs.

<00001> 000C064A P WM_KEYDOWN nVirtKey:VK_PACKET cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<00002> 000C064A P WM_CHAR chCharCode:'63' (63) cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<00003> 000C064A P WM_KEYUP nVirtKey:VK_PACKET cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:1 fUp:1
<00004> 000C064A P WM_KEYDOWN nVirtKey:VK_PACKET cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<00005> 000C064A P WM_CHAR chCharCode:'63' (63) cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:0 fUp:0
<00006> 000C064A P WM_KEYUP nVirtKey:VK_PACKET cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:1 fUp:1

由于它们都产生相同的输出,我不能看到什么是送,实际上标识的独特符号。

Since they all produce the same output I can't see what is sent that actually identifies the unique glyph.

我知道,SendInput有KEYEVENTF_UNICODE参数用于发送Unicode字符。但这些人物似乎是在某种扩展的Unicode的页面。除了16位Unicode范围(U + 0000到U + FFFF)C#的char或在INPUT结构可以代表短期wScan值。

I'm aware that SendInput has a KEYEVENTF_UNICODE parameter for sending unicode characters. But these characters seem to be in some sort of extended unicode page. Beyond the 16-bit unicode range (U+0000 to U+FFFF) a C# char or the short wScan value in the INPUT struct can represent.

下面是我的SendCharUnicode方法。

Here is my SendCharUnicode method.

public static void SendCharUnicode(char ch)
{
    Win32.INPUT[] input = new Win32.INPUT[2];

    input[0] = new Win32.INPUT();
    input[0].type = Win32.INPUT_KEYBOARD;
    input[0].ki.wVk = 0;
    input[0].ki.wScan = (short)ch;
    input[0].ki.time = 0;
    input[0].ki.dwFlags = Win32.KEYEVENTF_UNICODE;
    input[0].ki.dwExtraInfo = Win32.GetMessageExtraInfo();

    input[1] = new Win32.INPUT();
    input[1].type = Win32.INPUT_KEYBOARD;
    input[1].ki.wVk = 0;
    input[1].ki.wScan = (short)ch;
    input[1].ki.time = 0;
    input[1].ki.dwFlags = Win32.KEYEVENTF_UNICODE | Win32.KEYEVENTF_KEYUP;
    input[1].ki.dwExtraInfo = Win32.GetMessageExtraInfo();

    Win32.SendInput(2, input, Marshal.SizeOf(typeof(Win32.INPUT)));
}

这篇关于使用SendInput发送Unicode字符超出U + FFFF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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