How would I go about sending a string of characters as a keystroke in C#? An example would be opening notepad or a browser and having the string populate in the address bar or notepad file. I want to be able to just manually open an application and see my string appear. I've already tried passing it by process and using handlers to open the application, then having the string populate the file. A snippet of this has been attached below. I've also looked into the input simulator at codeplex.com. Is it possible to do this without using the input simulator?
namespace StringOutput
{
class StringSend : Form
{
[DllImport("USER32.dll")]
static extern bool ShowWindow(IntPtr point, int nCmdShow);
public static void Main()
{
Process notepad = new Process();
notepad.StartInfo.FileName = @"C:\Windows\Notepad.exe";
notepad.Start();
notepad.WaitForInputIdle();
IntPtr p = notepad.MainWindowHandle;
ShowWindow(p, 1);
SendKeys.SendWait("Testing");
}
}
}