keybs_event in C# not emulating commas

249 Views Asked by At

I have a C# program which is running on a windows mobile 6.1 device. It needs to print out comma delimited lists as keyboard events so that the user can dump them into whatever program is open at the time. However, the keybd_event method is ignoring the commas and just printing out the numbers one after another. Here is a sample with a number hard coded into it:

byte[] bBuf = Encoding.ASCII.GetBytes("22108,");

for (int i = 0; i < bBuf.Length; i++) 
{
 System.Diagnostics.Debug.WriteLine("buffer: " + bBuf[i]);
 keybd_event(bBuf[i], 0x00, keyFlag.KEYEVENTF_KEYDOWN, 0);
 System.Threading.Thread.Sleep(2);
 keybd_event(bBuf[i], 0x00, keyFlag.KEYEVENTF_KEYUP, 0);
 System.Threading.Thread.Sleep(2);
}

This will print out "22108".

Is there something special about the comma character which causes it to be ignored and if so, how do I get around this?

1

There are 1 best solutions below

0
On

You have to pass 0xBC for comma - check this out http://msdn.microsoft.com/en-us/library/dd375731(v=vs.85).aspx