Page 1 of 1

How to make a simple screenshot taker

Posted: Sat Nov 06, 2010 2:01 pm
by Vikhedgehog
In this tutorial you will learn how to make a screenshot taker in Visual Basic 2008, I hope. lmao; The program will have a capture button, a save button and a picturebox. If the user presses the capture button the program will take a screenshot and place it in the picturebox. By pressing the save button the content in the picturebox (our screenshot) will be saved as a Bitmap image. You can also save it as a jpg file, but for that you will need to convert the screenshot first. cryer;
1. Double click the Capture button and write:
Code: Select all
Dim bounds As Rectangle
        Dim screenshot As System.Drawing.Bitmap
        Dim graph As Graphics
        bounds = Screen.PrimaryScreen.Bounds
        screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
        graph = Graphics.FromImage(screenshot)
        graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
        PictureBox1.Image = screenshot

2. Double click the Save button and write:
Code: Select all
Dim savefiledialog1 As New SaveFileDialog
        Try
            savefiledialog1.Title = "Save File"
            savefiledialog1.FileName = "*.bmp"
            savefiledialog1.Filter = "Bitmap |*.bmp"
            If savefiledialog1.ShowDialog() = DialogResult.OK Then
                PictureBox1.Image.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
            End If
        Catch ex As Exception
            'If the program gets an error nothing should be done
        End Try
Finally, debug it! It should work now. If you get an error, let me know! I hope you understand now how to make a screenshot taker! dunnno;

Re: How to make a simple screenshot taker

Posted: Sat Nov 06, 2010 2:03 pm
by Cheatmasterbw
Nice Tutorial!

Re: How to make a simple screenshot taker

Posted: Sat Nov 06, 2010 5:23 pm
by XTechVB
this has been done countless times but still Nice Tutorial