Recording video from a given window or an application, the code samples:

The code samples below demonstrate how to use Screen Capturing SDK to autmatically record video from a given window or an application. The property .WindowToCapture is used to define the window title search string. In these samples below we are recording video from the Internet Explorer browser by setting .WindowToCapture = “Internet Explorer”.

Sound for the video is recorded from the default recording line by default (if user can 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.
IMPORTANT: before running this sample run Internet Explorer browser (this sample will record video from the IE browser).

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.catWindow

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

    ' set the window to capture from
    MsgBox("Please run Internet Explorer (this sample will capture video from IE) and click OK")

    ' set the title (or name) of the window to capture from
    capturer.WindowToCapture = "Internet Explorer"

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

  ' start capturing
    capturer.Run()

    ' wait for 20 seconds
    Thread.Sleep(20000)

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

    ' open the output video
    Process.Start("CaptureGivenWindow.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.
IMPORTANT: before running this sample run Internet Explorer browser (this sample will record video from the IE browser).

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

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.catWindow; // set capturing area type to Mouse type (to record from the given area near the mouse)
      
      capturer.OutputFileName = "GivenWindowCaptured.avi"; // set output video filename

      // set window to capture
      MessageBox.Show("Please run Internet Explorer (this sample will capture video from IE) and click OK");
     
      // set window to capture to Internet Explorer to capture video from Internet Explorer
      capturer.WindowToCapture = "Internet Explorer";

      // 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("GivenWindowCaptured.avi");
    }
  }
}

3) Visual Basic 6 and VBScript (VBS)

IMPORTANT: before running this sample run Internet Explorer browser (this sample will record video from the IE browser).

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

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

    ' set capturing type to the caWindow =1 to capture the given window
    capturer.CapturingType = 1

    MsgBox "This script will record video from Internet Explorer for 10 seconds. Please run Internet Explorer and click OK"

    capturer.WindowToCapture = "Internet Explorer"


    ' output video width
    capturer.OutputWidth = 320

    ' output video height
    capturer.OutputHeight = 320

    ' 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