.Net: running an external program and getting a screen

I can execute an external console program using C # and get its outputs thanks to the System.Diagnostics.Process class.

Is there any way to execute an external program, because this is not a console program, and get its outputs?

Suppose we have some "program.exe", suppose this is a 2D game, for example. Is it possible to get a video stream from it? For example, in an array of pixels.

+4
source share
1 answer

Yes it is possible. Start the process using the Process class. You will need to find out the name of the window you want to capture. Then use win32 api (pinvoked) FindWindow, GetWindowDC, .. to get a bitmap at regular intervals. this approach is explained here: http://www.nullskull.com/q/10087766/capturewindow-in-cnet-20-windows-application.aspx

Another approach is to capture a rectangle of the screen, Capturing a screen shot using .NET . you can get the bounding box of the window using win32 api GetWindowRect

+2
source

Source: https://habr.com/ru/post/1494923/


All Articles