1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
// Die Namensräume System.Runtime.InteropServices
// und System.Diagnostics werden benötigt
[DllImport("User32.dll", SetLastError = true)]
public static extern int SetForegroundWindow(IntPtr hwnd);
int ID;
// Hier kann zum Beispiel "Notepad.exe" übergeben werden
private void ProzessErstellen(string Programmname)
{
Process P = new Process();
P.StartInfo.FileName = Programmname;
P.Start();
ID = P.Id;
}
private void TextSenden(string Text)
{
System.IntPtr MainHandle = Process.GetProcessById(ID).MainWindowHandle;
SendKeys.Send(Text);
SetForegroundWindow(MainHandle);
}
|