0

I have two forms. One is "myVirtualKeyboard" and the other "form1", which contains username and password fields.

I can bring up the virtual keyboard, but typing at the virtual keyboard does insert the text into the the username and password fields.

This is the code:

VirtualKeyboard.cs:

private void btn_1_Click(object sender, EventArgs e) {
    int numberOne = 1;              
    String one = numberOne.ToString();
    SendKeys.Send(one);
}

Form1.cs:

private void button2_Click(object sender, EventArgs e) {
    VirtualKeyboard vk = new VirtualKeyboard();
    vk.Show();
}

I'm using Visual Studio 2010, C#

RBT
  • 24,161
  • 21
  • 159
  • 240
MN0903
  • 1
  • 2
  • Improved code indenting. – juunas Jan 08 '17 at 16:37
  • Are you using Windows Forms? And is your problem that when you type into the virtual keyboard form, the key presses are not submitted to the first form? – juunas Jan 08 '17 at 16:40
  • You need some sort of global keyboard hookup module like [this](http://stackoverflow.com/questions/604410/global-keyboard-capture-in-c-sharp-application) or [this](https://www.codeproject.com/articles/7294/processing-global-mouse-and-keyboard-hooks-in-c). Once you capture the keystroke then somehow you need to send it to `Form1` instead with focus on the `username` or `password` fields. OR once you have intercepted the key stroke, may be you can even grab the control through `Controls` collection for `Form1` and then append the key stroke into the existing content of the text boxes. – RBT Jan 10 '17 at 01:18
  • In the question its mentioned "virtual keyboard does insert the text into the the username and password fields". So what's the problem ? Should it be does not? @juunas asked the same. – Mukul Varshney Jan 10 '17 at 04:36

0 Answers0