Tuesday 1 June 2021

Screen Capture in C#

using System;

using System.Drawing;

using System.Drawing.Imaging;

using System.Threading;


 

int i = 0;

            do

            {

                i++;

                Bitmap bitmap = new Bitmap(1920, 1080);

                Graphics graphics = Graphics.FromImage(bitmap as Image);

                graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);

                Random rnd = new Random();

                int rndNumber = rnd.Next(1, 10000);

                //var n1 = i + rndNumber;

                var ImgName = $"{i}_{rndNumber}_test";

                bitmap.Save($"E:\\FreeSoftwareTraining\\ScreenImg\\{ImgName}.jpeg", ImageFormat.Jpeg);

                Thread.Sleep(30000);

            }

            while (true);

No comments:

Post a Comment