Get a running process' dimensions


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); }


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

<ol><li>get the main window handle (<a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.mainwindowhandle.aspx" rel="nofollow">Process.MainWindowHandle</a>).</li> <li>Get the window height using the win32 API function <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms633519%28v=vs.85%29.aspx" rel="nofollow">GetWindowRect</a></li> </ol>

This <a href="https://stackoverflow.com/a/6485074/52136" rel="nofollow">answer</a> 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 <a href="https://stackoverflow.com/questions/79111/net-c-getting-child-windows-when-you-only-have-a-process-handle-or-pid" rel="nofollow">question/answer(s)</a> describes getting all of the windows for a process.


  • Excel 2016 and ODBC driver for PostgreSQL
  • Add click to imagebutton inside gridview dynamically
  • cmd error: 'ANT' is not recognized as an internal or external command
  • Parsing a CSV file for a multiple row rows using new Java 8 Streams API
  • CameraCaptureTask of Windows Phone 8 App is not working in Windows 10?
  • How to integrate Struts2 with Thymeleaf?
  • Facebook Login using PHP SDK not working
  • Post hoc tests with ezANOVA output
  • Android: adding text color,background and font size to optionsmenu
  • ExecuteSQL doesn't select table if it having dateTime Offset value?
  • Samples, isosamples, and how they affect contour lines
  • Python: Referring to an Exception Class Created with PyErr_NewException in an Extension Module
  • Sync two textboxes with different models
  • org.springframework.security.oauth2.common.exceptions.InvalidGrantException: Bad credentials
  • Closing dropdown in Spinner in Android
  • search the database based on the value selected from database
  • Storyboard iOS MBProgressHUD
  • JS showModalDialog not working in chrome as modal
  • magento 2 rest api : get cart items with images
  • Can't perform CORS request using Angularjs
  • Limit number of button clicks
  • Working with codeception and laravel
  • VS2010: Ctrl-PgUp / -PgDown like in browsers
  • How to use array in autohotkey?
  • How to make Rss News Reader application in android …? [closed]
  • Compiling multiple source files in Rcpp
  • Generate and export point cloud from Project Tango
  • How to run chrome.tabs.insertCSS from the background page on each page?
  • Tensorflow Dataset API restore Iterator after completing one epoch
  • Calculate time from document
  • 'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs
  • Amazon Elastick BeanStalk error: Failed to create the AWS Elastic Beanstalk application version
  • How to turn off notice reporting in xampp?
  • Can a PHP script be scheduled to run at a specific time or after a specific amount of time has expir
  • reshape/remould data frame to create normalized bar chart and pie chart
  • Functions by reference or by variable, which to use when?
  • Bad automatic Triangulation with Mayavi for coloring a surface known only by its corner
  • calling IO Operations from thread in ruby c extension will cause ruby to hang