SendKeys.SendWait doesn't works

10,184

You'll need to do a little work, and it changes depending on the version of Windows. There's an MSDN page that has a good explanation and an example:

http://msdn.microsoft.com/en-us/library/ms171548.aspx

Share:
10,184
Guy
Author by

Guy

Updated on June 27, 2022

Comments

  • Guy
    Guy almost 2 years

    My target is to send keyboard events to external application. From my application, I'm launching a C# exe (console application) that bring the target application to the front and uses SendKeys.SendWait to send keyboards events. I ran into a rate case were the command don't have any affect. When debugging it, it works but when running it not in debug it fails. I think it as something to do with the fact that when debugging my application is the active application.

  • Guy
    Guy about 14 years
    Thanks for the link. I don't understand what should I do I'm using sendWait run with .NET Framework 3.0 and experiencing the problem.
  • philiphobgen
    philiphobgen about 14 years
    Read everything on that page from "Simulating Keyboard Input" down. There's a section titled "To send a keystroke to a different application" it shows an example of sending key to another application using sendWait. You need to read it all though, as it points out issues that you might get.
  • Abhishek
    Abhishek over 6 years
    Like stated in the answer, it also depends upon the version of .NET framework being used. It worked for me on .NET 4.5 but didn't work on .NET 4.5.3.