Q:

C# GeckoFX - How to use SendKeyEvent with Vietnamese string

I used GeckoFX instead of .NET webControl component to make automative tool, in GeckoFX supported method was called: SendKeyEvent().
I wanna send string to browser with vietnamese message by this method but output is encrypted string:
Sample string:

đây là tiếng việt

And here my code
byte[] tmp_cmt = Encoding.UTF8.GetBytes(comment);
char[] tmp_rsl = comment.ToCharArray();
txtLog.AppendText("Starting COMMENT....\n");
webBrowser1.Window.DomWindow.Focus();
int a = 0;
while (a < comment.Length)
{
    Thread.Sleep(100);
    bool sd = webBrowser1.Window.WindowUtils.SendKeyEvent("keypress", 0, tmp_cmt[a], 0, true);
    if (!sd) { Utilityx.Log(tmp_cmt[a].ToString() + " - "); a++; }
    Application.DoEvents();
}
txtLog.AppendText("Pressing `Enter` key to submit comment...\n");
webBrowser1.Window.WindowUtils.SendKeyEvent("keydown", 13, 0, 0, true);
webBrowser1.Window.WindowUtils.SendKeyEvent("keyup", 13, 0, 0, true);

And here result: 

?ay l? ti?ng vi?t

How to made it work ?
Thanks in advance !

A:

The signature for the method is
SendKeyEvent(string aType, int aKeyCode, int aCharCode, int aModifiers, bool aPreventDefault)

I don't know if keyCode, for which you sent 0 is important, but certainly charCode is not a byte in the UTF8 encoding of the string. Instead, you should try to use (int)comment[a]
The problem I see here is that probably for Vietnamese characters multiple keys need to be pressed. If SendKeyEvent doesn't know how to translate it itself, then probably you need to do some complicated key emulations.

