[英]C# Teststack.White automating Winforms Menu (ControlType.Menu) which is not child of the main window
[英]Capturing a screenshot of teststack.white window in c# -winforms
有人可以帮我编写代码来捕获 teststack.white 窗口的屏幕截图吗? 我尝试了以下代码
Rectangle bounds = this.Bounds;
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new System.Drawing.Point(bounds.Left, bounds.Top), System.Drawing.Point.Empty, bounds.Size);
}
bitmap.Save(@"C:\Users\Desktop\test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
这将捕获表单的屏幕截图。 如果代替 this.bounds ,我输入 teststack.white 窗口边界,它说不能将 system.windows.rect 转换为 system.drawing.rectangle? 有人可以向我提供代码来进行排序吗? 提前致谢。
当然,这很简单:
Desktop.TakeScreenshot("C:\\white-framework.png", System.Drawing.Imaging.ImageFormat.Png);
如果您需要在捕获图像后对其进行操作,您可以这样做:
Bitmap bitmap = Desktop.CaptureScreenshot();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.