![](/img/trans.png)
[英]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.