3

I'm trying to grab a screen shot of a specific x, y location in an application. Is there any way to get a running app in a Process object, then get the dimensions of it?

Something like:

Process[] processlist = Process.GetProcesses();
foreach (Process proc in processlist)
{
Console.WriteLine("Process: {0} ID: {1}", proc.Width, proc.Height);
}
Dan J
  • 16,319
  • 7
  • 50
  • 82
Colbs
  • 587
  • 10
  • 25

1 Answers1

7

There are probably other ways to do this but here's a quick high level solution:

  1. get the main window handle (Process.MainWindowHandle).
  2. Get the window height using the win32 API function GetWindowRect

This answer to a SO question shows getting the window size and then setting it.

Edit: I realize this answer assumes that the process only has a single window. This SO question/answer(s) describes getting all of the windows for a process.

Community
  • 1
  • 1
Ken Henderson
  • 2,828
  • 1
  • 18
  • 16