You can use the .NET SendKeys class to send keystrokes to an application you do not own. The target application must be active to be able to retrieve the keystrokes. Therefore before sending you have to activate your target application. You do so by getting a handle of the window and pinvoking into SetForegroundWindow with your handle.
Here is some example code to get you started:
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lp1, string lp2);
[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetForegroundWindow(IntPtr hWnd);
private void button1_Click(object sender, EventArgs e)
{
IntPtr handle = FindWindow("ConsoleWindowClass", "Eingabeaufforderung");
if (!handle.Equals(IntPtr.Zero))
{
if (SetForegroundWindow(handle))
{
// send
SendKeys.Send("Greetings from Postlagerkarte!");
// send key "Enter"
SendKeys.Send("{ENTER}");
}
}
}