Skip to content

Instantly share code, notes, and snippets.

@dmorrison42
Created December 17, 2016 17:53
Show Gist options
  • Save dmorrison42/ec31c2edea61dac0c2e28bae3a145edd to your computer and use it in GitHub Desktop.
Save dmorrison42/ec31c2edea61dac0c2e28bae3a145edd to your computer and use it in GitHub Desktop.
Capture a hidden dialog c#
private async void button1_Click(object sender, EventArgs e)
{
await Task.Delay(1000);
await Task.Run(() =>
{
var fileName = @"C:\Users\dan\Desktop\Folder\bitmap.png";
var subwindow = new Slave();
subwindow.ShowInTaskbar = false;
subwindow.Show();
subwindow.DesktopLocation = new Point(int.MinValue, int.MinValue);
var drawing = new Bitmap(subwindow.Height, subwindow.Width);
subwindow.DrawToBitmap(drawing, new Rectangle(new Point(0, 0), new Size(subwindow.Width, subwindow.Height)));
drawing.Save(fileName);
// Process.Start(fileName);
subwindow.Close();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment