【发布时间】:2017-10-08 19:18:46
【问题描述】:
我想自动创建使用我的气球提示从通知图标截取的屏幕截图,以便可以轻松验证我的应用程序支持的不同语言的外观。问题是虽然在 Windows 7 上显示在屏幕上,但屏幕截图中没有气球提示。
我已经尝试过Capture screenshot of active window? 的解决方案,例如
// From http://www.developerfusion.com/code/4630/capture-a-screen-shot/
var sc = new ScreenCapture();
trayIcon.ShowBalloonTip(10000, "My Title", "My message", ToolTipIcon.Info);
Thread.Sleep(2000); // Just to make sure that the balloon tip is shown
sc.CaptureScreenToFile("MyScreenshot.png", ImageFormat.Png);
和
Rectangle bounds = Screen.GetBounds(Point.Empty);
using(Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using(Graphics g = Graphics.FromImage(bitmap))
{
trayIcon.ShowBalloonTip(10000, "My Title", "My message", ToolTipIcon.Info);
Thread.Sleep(2000); // Just to make sure that the balloon tip is shown
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
}
bitmap.Save("MyScreenshot.png", ImageFormat.Png);
}
但两者都在不显示气球提示的情况下截取屏幕截图。那么,有没有办法以编程方式截取包含气球提示的屏幕截图?
奖励信息:在 Windows 10 上,气球提示被强制进入正常的通知系统,并按预期截屏。
【问题讨论】:
-
您需要添加 CopyPixelOperation.CaptureBlt 以便您还可以捕获分层窗口。
-
@HansPassant 成功了!根据您的建议,我找到了解决我问题的答案stackoverflow.com/questions/3072349/…。
标签: c# screenshot