Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capturing virtual screen (all monitors)

I am trying to get a screenshot of the whole virtual screen. This means, an image of not just the primary screen, but every screen connected to the computer.

Is there a way to do that? I tried using this, but it didn't work:

Bitmap b = new Bitmap(SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height);
Graphics g = Graphics.FromImage(b);
this.Size = new Size(SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height);
g.CopyFromScreen(0, 0, 0, 0, b.Size);
like image 453
John Avatar asked Mar 31 '11 12:03

John


People also ask

Can I use virtual machine on multiple monitors?

Enable multiple displays for virtual machine To use your virtual machine on several displays in Full Screen mode, go to View menu > enable Use All Displays in Full Screen: NOTE: if you have more than two displays, it is not possible to select what displays to use with virtual machine and what not.

How do I record my screen on multiple monitors?

In 'Screen Recording' mode, click the 'Select a recording area' option in the menu, and then click on an empty area on the Windows desktop to select the entire dual monitor as the recording area. If you then press the record start button (or hotkey F12), the entire dual monitor will be recorded (Recommended).

How do I split my monitor into two virtual monitors?

Virtual monitors are created in UltraView Desktop Manager's Monitor Configuration utility. Click on the monitor you want to split, and then click the button "Splits and Padding." Below are 55 examples of layouts you can create on a 4K UHD (3840×2160 resolution) monitor in landscape orientation.


1 Answers

The documentation says: Graphics.CopyFromScreen(Int32, Int32, Int32, Int32, Size): Performs a bit-block transfer of the color data, corresponding to a rectangle of pixels, from the screen to the drawing surface of the Graphics." But the virtual screen is not necessarily a rectangle: imagine two monitors with 1920x1200 and 1280x1024 resolutions. So what you need to do is create a bitmap like you do, then enumerate your monitors and execute CopyFromScreen() for each of them.

Edit: If, for instance, you have two monitors, the one having 1280x1024 resolution standing on the left of 1920x1200 one, then the coordinates of the former would be (-1280,0) - (0, 1024). Therefore you need to execute memoryGraphics.CopyFromScreen(-1280, 0, 0, 0, s); where s is the Size(1280,1024). For the second one you need to call memoryGraphics.CopyFromScreen(0, 0, *1280*, 0, s); and s would be the Size(1920, 1200). Hope this helps.

like image 150
Igor Korkhov Avatar answered Sep 21 '22 00:09

Igor Korkhov