At the moment I open automatically a new form, loading a chart, make a screenshot only in RAM and sending it to my private chat in telegram. All good so far, but is there a way, to open the form silent (also not shown and not focusing / invisible) and screenshot the silent form?
This is atm my code and working fine but without a silent function. anyone can help me?
_f2 = new Form2();
_f2.Show();
while(true)
{
if(Form2Closed == true)
{
Form2Closed = false;
break;
}
await Task.Delay(1000);
}
// loading chart stuff
var frm = Form2.ActiveForm;
using (MemoryStream stream = new MemoryStream())
{
using (var bmp = new Bitmap(frm.Width, frm.Height))
{
frm.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
bmp.Save(stream, ImageFormat.Png);// "screenshot.png");
stream.Seek(0, SeekOrigin.Begin);
bmp.Dispose();
// sending stuff
}
}