Question

I have a windows forms application containing a button and a textbox. At "button_click_event" this code is executed:

System.Diagnostics.Process.Start("osk.exe");

The keyboard shows, yet no text appears on the textbox as I type on said keyboard.

Was it helpful?

Solution

What is happening is that the on screen keyboard is sending information to the Focused Control which in your case is the Button that initiated the Keyboard. Try setting focus to to your textbox after creating the keyboard.

private void button1_Click(object sender, EventArgs e)
{
    System.Diagnostics.Process.Start("osk.exe");
    //SetFocus to your TextBox here
    textBox1.Focus();
}

To close it do something like this

private void button2_Click(object sender, EventArgs e)
{
    var procs = Process.GetProcessesByName("osk");
    if (procs.Length != 0)
        procs[0].Kill();

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top