How to I get the window handle by giving the process name that is running?

Viewed 58429

How can I get the window handle by giving the process name or window title in c#.. given the process is in running already

1 Answers

You can use the Process class.

Process[] processes = Process.GetProcessesByName("someName");

foreach (Process p in processes)
{
    IntPtr windowHandle = p.MainWindowHandle;

    // do something with windowHandle
}
Related