QUESTIONS OR COMMENTS ABOUT PRODUCTS? WRITE US AT SUPPORT@BYTESCOUT.COM OR USE THIS FORM

How to record entire screen into a using with Bytescout Screen Capturing SDK

Entire screen recording code sample:

This code sample shows how to use Screen Capturing SDK to record entire screen activity into a video (AVI) with sound. capScreen recording type records the whole desktop screen into a video with the given width and height. Additionaly it records sound (by default) from the default recording line.

This mode can be used if you want to record the entire screen and record voice comments (for what he/she do) from user.

1) Visual Basic .NET

Create new VB.NET Console project in Visual Studio. Click Project | Add Reference.. and add the reference to Bytescout Screen Capturing Lib on the COM tab and click OK. Then use the code snippet below:

 

<font color="black" face="Courier New" size="2"><font color="#0000ff">Imports</font> System.Threading<br>
<font color="#0000ff">Imports</font> System.Diagnostics<br>
<br>
<font color="#0000ff">Imports</font> BytescoutScreenCapturingLib <font color="#008000">' import bytescout screen capturer activex object</font><br>
<br>
<font color="#0000ff">Module</font> Module1<br>
<br>
&nbsp;&nbsp;<font color="#0000ff">Sub</font> Main()<br>
&nbsp;&nbsp;<font color="#008000">' create capturer class</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">Dim</font> capturer <font color="#0000ff">As</font> <font color="#0000ff">New</font> CapturerClass()<br>
&nbsp;&nbsp;<font color="#008000">' set capturing area to the region type (to capture from given region on the screen)</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;capturer.CapturingType = CaptureAreaType.catScreen<br>
&nbsp;&nbsp;<font color="#008000">' output video filename</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;capturer.OutputFileName = <font color="#a31515">"EntireScreenCaptured.avi"</font><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">' set width and height of output video</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;capturer.OutputWidth = 320<br>
&nbsp;&nbsp;&nbsp;&nbsp;capturer.OutputHeight = 240<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">' start capturing</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;capturer.Run()<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">' wait for 25 seconds</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;Thread.Sleep(25000)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">' stop capturing and flush AVI video file into the disk</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;capturer.<font color="#0000ff">Stop</font>()<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">' open the output video </font><br>
&nbsp;&nbsp;&nbsp;&nbsp;Process.Start(<font color="#a31515">"EntireScreenCaptured.avi"</font>)<br>
<br>
&nbsp;&nbsp;<font color="#0000ff">End</font> <font color="#0000ff">Sub</font><br>
<br>
<font color="#0000ff">End</font> <font color="#0000ff">Module</font></font>

 

2) Visual C# .NET

Create new C# Console project in Visual Studio. Click Project | Add Reference.. and add the reference to Bytescout Screen Capturing Lib on the COM tab and click OK. Then use the code snippet below:

 

<font color="black" face="Courier New" size="2">using System;<br>
using System.Collections.Generic;<br>
using System.Text;<br>
using System.Threading;<br>
using System.Diagnostics;<br>
<br>
using BytescoutScreenCapturingLib; // import bytescout screen capturing activex <font color="#0000ff">object</font><br>
<br>
<font color="#0000ff">namespace</font> SimpleCaptureCSharp<br>
{<br>
&nbsp;&nbsp;<font color="#0000ff">class</font> Program<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">static</font> void Main(<font color="#0000ff">string</font>[] args)<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CapturerClass capturer = <font color="#0000ff">new</font> CapturerClass(); // create <font color="#0000ff">new</font> screen capturer <font color="#0000ff">object</font><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;capturer.CapturingType = CaptureAreaType.catScreen; // <font color="#0000ff">set</font> capturing area type <font color="#0000ff">to</font> catScreen <font color="#0000ff">to</font> capture whole screen<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;capturer.OutputFileName = <font color="#a31515">"EntireScreenCaptured.avi"</font>; // <font color="#0000ff">set</font> output video filename<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// <font color="#0000ff">set</font> output video width <font color="#0000ff">and</font> height<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;capturer.OutputWidth = 320;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;capturer.OutputHeight = 240;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;capturer.Run(); // run screen video capturing<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thread.Sleep(15000); // wait <font color="#0000ff">for</font> 15 seconds<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;capturer.<font color="#0000ff">Stop</font>(); // <font color="#0000ff">stop</font> video capturing<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Process.Start(<font color="#a31515">"EntireScreenCaptured.avi"</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;}<br>
}</font>

 

2) Visual Basic 6 and VBScript (VBS)

 

<font color="black" face="Courier New" size="2"><font color="#008000">' create video capturer activex object</font><br>
<font color="#0000ff">Set</font> capturer = CreateObject(<font color="#a31515">"BytescoutScreenCapturing.Capturer"</font>)<br>
<br>
<font color="#008000">' set output video file name</font><br>
capturer.OutputFileName = <font color="#a31515">"EntireScreenCaptured.avi"</font><br>
<br>
<font color="#008000">' set capturing type to the caScreen =3 to capture the entire screen</font><br>
capturer.CapturingType = 3<br>
<br>
<font color="#008000">' output video width</font><br>
capturer.OutputWidth = 320<br>
<br>
<font color="#008000">' output video height</font><br>
capturer.OutputHeight = 320<br>
<br>
MsgBox <font color="#a31515">"This script will record 320x240 video from entire screen for 10 seconds. Output video will go to EntireScreenCaptured.avi"</font><br>
<br>
<font color="#008000">' run video capturing </font><br>
capturer.Run()<br>
<br>
<font color="#008000">' wait for 10 seconds (10000 msec)</font><br>
WScript.Sleep(10000)<br>
<br>
<font color="#008000">' stop capturing</font><br>
capturer.<font color="#0000ff">Stop</font>()<br>
<br>
<font color="#008000">' destroy Capturer object so the video will be saved into the disk</font><br>
<font color="#0000ff">Set</font> capturer = <font color="#0000ff">Nothing</font></font>