Any method to output the screenshot of an active form?
Windows. Hit the PrtScn button/ or Print Scrn button, to take a screenshot of the entire screen: When using Windows, pressing the Print Screen button (located in the top right of the keyboard) will take a screenshot of your entire screen. Hitting this button essentially copies an image of the screen to the clipboard.
Use the Control.DrawToBitmap() method. For example:
private void timer1_Tick(object sender, EventArgs e) { var frm = Form.ActiveForm; using (var bmp = new Bitmap(frm.Width, frm.Height)) { frm.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height)); bmp.Save(@"c:\temp\screenshot.png"); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With