Assume that notepad.exe is opening and the it\'s window is inactive. I will write an application to activate it. How to make?
Update: The window title i
You'll need to P/invoke SetForegroundWindow(). Process.MainWindowHandle can give you the handle you'll need. For example:
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
class Program {
static void Main(string[] args) {
var prc = Process.GetProcessesByName("notepad");
if (prc.Length > 0) {
SetForegroundWindow(prc[0].MainWindowHandle);
}
}
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
}
Note the ambiguity if you've got more than one copy of Notepad running.