简体   繁体   English

虚拟桌面截图

[英]Virtual desktop screenshot

I'm creating virtual desktop using interop C#. 我正在使用互操作C#创建虚拟桌面。 Then I'm launching few programs within. 然后,我在其中启动几个程序。

Now I need to make screenshots of this desktop from time to time and display it on form. 现在,我需要不时制作此桌面的屏幕截图,并将其显示在表单上。 It works fine for current active desktop, but not for created one. 它适用于当前活动的桌面,但不适用于已创建的桌面。

Bitmap screen = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                          Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
Graphics ss = Graphics.FromImage(screen);
ss.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, 
                  Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);

How can I achieve this goal? 我怎样才能实现这个目标? It doesn't matter whether I will use .NET functions or WinAPI. 我将使用.NET函数还是WinAPI都没有关系。

You cannot screenshot the desktop if it is not active. 如果桌面不处于活动状态,则无法对其进行屏幕快照。 The only thing as I know off is screenshoting the windows and somehow with the position of the windows making the desktop screenshot. 据我所知,唯一的事情就是对窗口进行屏幕截图,并通过某种方式确定窗口的位置来制作桌面屏幕截图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM