Windows Forms: Capture Screenshot & Record your computer screen in C#
By FoxLearn 7/25/2017 8:36:30 PM 7.37K
How to Capture Screenshot & Record your computer screen in C#
Step 1: Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "CaptureScreenshot" and then click OK
Step 2: Design your form as below
Step 3: Add code to handle your form as below
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace CaptureScreenshot { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnCapture_Click(object sender, EventArgs e) { Bitmap bm = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); Graphics g = Graphics.FromImage(bm); g.CopyFromScreen(0, 0, 0, 0, bm.Size); pictureBox.Image = bm; } //Capture screenshot void Capture() { while (true) { Bitmap bm = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); Graphics g = Graphics.FromImage(bm); g.CopyFromScreen(0, 0, 0, 0, bm.Size); pictureBox.Image = bm; Thread.Sleep(1000); } } private void btnRecord_Click(object sender, EventArgs e) { //Start new thread to record your screen Thread t = new Thread(Capture); t.Start(); } } }
VIDEO TUTORIALS
- Windows Forms: Progress Bar in C#
- How to create a Lucky Draw games in C#
- Windows Forms: Youtube Search with Paging in C#
- Windows Forms: How to Create a Random Password Generator in C#
- Windows Forms: Tag Control in C#
- Windows Forms: Wait Form Dialog in C#
- Windows Forms: Text to speech in C#
- Windows Forms: Print Picture Box in C#