在双监视器WPF C#中捕获活动屏幕 [英] Capture active screen in dual monitor WPF C#
本文介绍了在双监视器WPF C#中捕获活动屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮我从双显示器上找到有源显示器屏幕。
i尝试下面的代码,我可以从中获取显示器屏幕的截图。
但是无法找到哪个是活动屏幕。
类似于alt + prtsc,它提供了有效的屏幕截图。
我尝试了什么:
Hi,
Please help me to find the active monitor screen from dual monitor.
i tried the below code from which i can get the screenshot of both the monitor screen.
But could not able to find which is active screen.
similar to alt+prtsc which gives active screenshot.
What I have tried:
Thread thread = new Thread(() =>
{
// Determine the size of the "virtual screen", which includes all monitors.
int screenLeft = SystemInformation.VirtualScreen.Left;
int screenTop = SystemInformation.VirtualScreen.Top;
int screenWidth = SystemInformation.VirtualScreen.Width;
int screenHeight = SystemInformation.VirtualScreen.Height;
// Create a bitmap of the appropriate size to receive the screenshot.
using (Bitmap bmp = new Bitmap(screenWidth, screenHeight))
{
// Draw the screenshot into our bitmap.
using (Graphics g = Graphics.FromImage(bmp))
{
g.CopyFromScreen(screenLeft, screenTop, 0, 0, bmp.Size);
}
// Do something with the Bitmap here, like save it to a file:
bmp.Save("D:/temp.png", ImageFormat.Png);
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
推荐答案
阅读: c# - 第二个屏幕截图 - Stack Overflow [ ^ ]
这篇关于在双监视器WPF C#中捕获活动屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文