C# Sending Keyboard Input

14,460

Solution 1

SendKeys.Send will help you with that.

Solution 2

Look at System.Windows.Forms.SendKeys.Send( string ). This allows key presses to be sent to the currently active application.

Update: just found this on MSDN forums: MSDN Forum

Share:
14,460

Related videos on Youtube

smack0007
Author by

smack0007

I'm an American computer programmer living and working in Germany.

Updated on April 16, 2022

Comments

  • smack0007
    smack0007 about 2 years

    How can I send keyboard input messages to either the currently selected window or the previously selected window?

    I have a program which I use to type some characters which are not present on my keyboard and I would like it if I could just send the input directly rather than me having to copy and paste all the time.

    EDIT:

    The application of this is typing the German Umlauts. I'm an American and I work in Germany. I'm working on an American keyboard and from time to time I have to type in the umlauts / the euro symbol / the sharp S. Currently I have a simple WinForms application with a textfield and some buttons with the extra characters on it. I type into the textfield and I can press the buttons to append text to the textfield. I then copy the text and paste it where ever. What would be nice though if I could just just hit one of the buttons and it would send the text where ever I'm typing / was typing. The current program works fairly well but I could make it better.

  • smack0007
    smack0007 almost 13 years
    I actually managed to implement this today. Took me long enough.