Generation

generate functionTue, 21 Mar 2023

get screenshot

using System; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Windows.Forms; namespace ScreenShot { public class Screen { public static void PrintScreen() { var bmpScreenShot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); var g = Graphics.FromImage(bmpScreenShot); g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, bmpScreenShot.Size, CopyPixelOperation.SourceCopy); var imagePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "screenshot.png"); bmpScreenShot.Save(imagePath, ImageFormat.Png); } } }

Questions about programming?Chat with your personal AI assistant