views:

154

answers:

1

I have developed a custom keypad using resco controls in my application I have currently handled the backspace button click event with the following code

private void customKeyboard1_KeyboardKeyUp(object sender, Resco.Controls.Keyboard.KeyPressedEventArgs e)
        {
            if (e.Key.Text == "Backspace")
            {
                Resco.Controls.Keyboard.CustomKeyboard.SendBackspace();
                e.Handled = true;
            }
        }

This works fine with the edit boxes in the application but not working in edit boxes in the web pages (for eg. on gmail username text box).

so is there any way to raise the KeyDown event manually

A: 

P/Invoke PostKeybdMessage.

EDIT 1

Something along these lines:

[DllImport("coredll.dll", SetLastError = true)]
internal static extern bool PostKeybdMessage(IntPtr hwnd, uint vKey, 
                                             uint flags, uint cCharacters, 
                                             uint[] pShiftStateBuffer, 
                                             uint[] pCharacterBuffer);

private static void SendChar(byte key)
{
    uint KeyStateDownFlag= 0x0080;    
    uint KeyShiftDeadFlag= 0x20000;    
    uint[] buf1 = new uint[] { (uint)key };    
    uint[] DownStates = new uint[] { KeyStateDownFlag };    
    uint[] DeadStates = { KeyShiftDeadFlag };
    PostKeybdMessage(new IntPtr(-1), 0, KeyStateDownFlag, 1, DownStates, buf1);
    PostKeybdMessage(new IntPtr(-1), 0, KeyShiftDeadFlag, 1, DeadStates, buf1);
}
ctacke
can you give some sample code
Sundar

related questions