C# - Take screenshot

  • 0 Replies
  • 80 Views

0 Members and 1 Guest are viewing this topic.

Offline Omega

    *
  • The Boss (Admin)
  • Black Hat Sec Member
  • Telegram: @BLACKHATSEC_FORUM
  • Posts: 190
  • Popularity: +1/-0
  • God of Malware
    • View Profile
    • Awards
« on: March 14, 2022, 09:24:53 AM »
C# - Take screenshot

Code
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

class screenshot
{
     void take()
     {
          // Create the path
          string path = Path.Combine(Directory.GetCurrentDirectory(), "ss.bmp");
             
          try
          {
               // Create a new bitmap class with the height and width of the screen
               Bitmap bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
               // Create new Graphics class..
               Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot);
               // Copy the screen image to the Graphics class
               gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
               // Save it to a path
               bmpScreenshot.Save(path, ImageFormat.Bmp);
          }
          catch { } // "should" never be hit :P
     }
}
  • Discord: BLACK HAT SEC#5222
  • [+]
  • [-]

  •