0

I need some help how to implement the following thing in C#: I got a Form, that has a textBox. When I click into the textBox it opens another Form that is a "keyboard" I made. I has buttons like Q, W, E etc. When I left click the Q button for example I would like to pass that button's text into that textBox.

grinderke
  • 29
  • 1
  • 5

1 Answers1

0

It would be hacky to do this. Since you need to know where the focus was before you clicked on your keyboard form. So you would need

  • Your Keyboard form
  • A loop that continuously gets the current focus on the screen. Lookup DllImport and GetFocus (and SetFocus)
  • Once a user clicks on your keyboard form you need to set focus back to the previous application and send that keyboard event to that other application. To do that check this: C# using Sendkey function to send a key to another application

Thats basically it, but some applications might not be responsive to your SendKeys feature if they are based on DirectInput for example.

Community
  • 1
  • 1
Wolf5
  • 16,600
  • 12
  • 59
  • 58