public static Rect GetWindowRect(String processName) { Process[] p = Process.GetProcessesByName(processName); Rect r; r.left = 0; r.right = 0; r.top = 0; r.bottom = 0; if (p.Length == 0) return r; IntPtr proc = p[0].MainWindowHandle; GetClientRect(proc, out r); return r; }