Menu Close

How can I program screen capture using C#

You are here:
< Back

– add a reference to the NET DLL of the package corresponding to the .NET Framework version of the .csproj project
– start from the following sample code:

public Form1()
{
   InitializeComponent();
}

VidGrab.VideoGrabber vg;

private void Form1_Load(object sender, EventArgs e)
{
   vg = new VidGrab.VideoGrabber();
   vg.Parent = this;
   vg.Location = new Point(100, 100);
   vg.VideoSource = VidGrab.TVideoSource.vs_ScreenRecording;
   vg.StartPreview();
}

private void Button1_Click(object sender, EventArgs e)
{
   vg.CaptureFrameTo(VidGrab.TFrameCaptureDest.fc_JpegFile, “c:\\myfolder\\snapshot.jpg”);
}

Last Updated On August 11, 2019