在 DotNetBrowser 中模拟外语输入

Simulate Foreign Language Input in DotNetBrowser

DotNetBrowser 支持输入模拟,但我找不到针对外语的方法。以下代码适用于英语。知道如何将 VirtualKeyCode 与非英文字符一起使用吗?

// Press TAB key to set focus to text field.
KeyParams paramers = new KeyParams(VirtualKeyCode.TAB, ' ');
browser.KeyDown(paramers);
browser.KeyUp(paramers);

// Type 'Hello' text in the focused text field.
paramers = new KeyParams(VirtualKeyCode.VK_H, 'H');
browser.KeyDown(paramers);
browser.KeyUp(paramers);

paramers = new KeyParams(VirtualKeyCode.VK_E, 'e');
browser.KeyDown(paramers);
browser.KeyUp(paramers);

paramers = new KeyParams(VirtualKeyCode.VK_L, 'l');
browser.KeyDown(paramers);
browser.KeyUp(paramers);

paramers = new KeyParams(VirtualKeyCode.VK_L, 'l');
browser.KeyDown(paramers);
browser.KeyUp(paramers);

paramers = new KeyParams(VirtualKeyCode.VK_O, 'o');
browser.KeyDown(paramers);
browser.KeyUp(paramers);

我找到了解决办法。文本是一个字符串。

var stringSplit = text.Split(' ');
            for (int i = 0; i < stringSplit.Length; i++)
            {
                var characters = stringSplit[i].ToCharArray();
                foreach (var character in characters)
                {
                    var keyParams = new KeyParams(VirtualKeyCode.NONAME, character);
                    browser.KeyDown(keyParams);
                    browser.KeyUp(keyParams);
                }
                if (i < stringSplit.Length-1)
                {
                    var spaceKey = new KeyParams(VirtualKeyCode.SPACE, ' ');
                    browser.KeyDown(spaceKey);
                    browser.KeyUp(spaceKey);
                }
            }