Code samples on recording video from the region on the screen:

Code samples below are demonstration use of Screen Capturing SDK for screen video recording from a predefined region on screen. The region is defined through the following properties: CaptureRectLeft, CaptureRectTop, CaptureRectWidth, CaptureRectHeight.

The sound track for the video is recorded from default recording line by default (if user need to record voice comments then you should change audio line to Mic line source)

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.

Imports System.Threading
Imports System.Diagnostics

Imports BytescoutScreenCapturingLib ' import bytescout screen capturer activex object

Module Module1

  Sub Main()
  ' create capturer class
    Dim capturer As New CapturerClass()
  ' set capturing area to the region type (to capture from given region on the screen)
    capturer.CapturingType = CaptureAreaType.catRegion

  ' output video filename
    capturer.OutputFileName = "GivenRegionCaptured.avi"

    ' set coordinates of the region to capture video from
    capturer.CaptureRectLeft = 50
    capturer.CaptureRectTop = 50

    capturer.CaptureRectWidth = 640
    capturer.CaptureRectHeight = 480

    ' set width and height of output video
    capturer.OutputWidth = 320
    capturer.OutputHeight = 240

  ' start capturing
    capturer.Run()

  ' wait for 10 seconds
    Thread.Sleep(10000)

  ' stop capturing and flush AVI video file into the disk
    capturer.Stop()


    ' open the output video
    Process.Start("GivenRegionCaptured.avi")
  End Sub

End Module

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.

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Diagnostics;

using BytescoutScreenCapturingLib; // import bytescout screen capturing activex object

namespace SimpleCaptureCSharp
{
  class Program
  {
    static void Main(string[] args)
    {
      CapturerClass capturer = new CapturerClass(); // create new screen capturer object

      capturer.CapturingType = CaptureAreaType.catRegion; // set capturing area type to catRegion to capture from the given region
      
      capturer.OutputFileName = "RegionCapture.avi"; // set output video filename

      capturer.CaptureRectLeft = 100; // set left coordinate of the rectangle region to record video from
      capturer.CaptureRectTop = 100; // set top coordinate of the rectangle region to record video from

      capturer.CaptureRectWidth = 640; // set width of the rectangle region to record video from
      capturer.CaptureRectHeight = 480; // set height of the rectangle region to record video from

      // set output video width and height
      capturer.OutputWidth = 320;
      capturer.OutputHeight = 240;

      capturer.Run(); // run screen video capturing

      Thread.Sleep(15000); // wait for 15 seconds

      capturer.Stop(); // stop video capturing

      Process.Start("RegionCapture.avi");
    }
  }
}

3) Visual Basic 6 and VBScript (VBS)

' create video capturer activex object
Set capturer = CreateObject("BytescoutScreenCapturing.Capturer")

' set output video file name
capturer.OutputFileName = "CaptureScreenVbs.avi"

' set capturing type to the caRegion =0 to capture the given region
capturer.CapturingType = 0

' set left coordinate of the rectangle to capture from
capturer.CaptureRectLeft = 100
' set top coordinate of the rectangle to capture from
capturer.CaptureRectTop = 100

' set width of the rectangle to capture from
capturer.CaptureRectWidth = 320
' set height of the rectangle to capture from
capturer.CaptureRectHeight = 240

MsgBox "This script will record video from the screen from region (100,100, 420, 350) for 10 seconds. Output video will go to PredefinedRegionCaptured.avi"

' run video capturing
capturer.Run()

' wait for 10 seconds (10000 msec)
WScript.Sleep(10000)

' stop capturing
capturer.Stop()

' destroy Capturer object so the video will be saved into the disk
Set capturer = Nothing