ByteScout Screen Capturing SDK - C++ (managed) - Record Screen Video From Given Window - ByteScout

ByteScout Screen Capturing SDK – C++ (managed) – Record Screen Video From Given Window

  • Home
  • /
  • Articles
  • /
  • ByteScout Screen Capturing SDK – C++ (managed) – Record Screen Video From Given Window

How to record screen video from given window in C++ (managed) and ByteScout Screen Capturing SDK

How to code in C++ (managed) to record screen video from given window with this step-by-step tutorial

The sample source code below will teach you how to record screen video from given window in C++ (managed). ByteScout Screen Capturing SDK is the screen video recording SDK helps in quick implementation of screen video recording. WMV, AVI, WebM output options are available with adjustable quality, video size, framerate and video and audio codec. Includes special features like live multiple blacking out of selected areas, recording from web cam as main source and as overlay, optional watermarks for output video. It can be used to record screen video from given window using C++ (managed).

Fast application programming interfaces of ByteScout Screen Capturing SDK for C++ (managed) plus the instruction and the code below will help you quickly learn how to record screen video from given window. In your C++ (managed) project or application you may simply copy & paste the code and then run your app! You can use these C++ (managed) sample examples in one or many applications.

Trial version of ByteScout Screen Capturing SDK is available for free. Source code samples are included to help you with your C++ (managed) app.

Try ByteScout Screen Capturing SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

AssemblyInfo.cpp
      
#include "stdafx.h" using namespace System; using namespace System::Reflection; using namespace System::Runtime::CompilerServices; using namespace System::Runtime::InteropServices; using namespace System::Security::Permissions; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly:AssemblyTitleAttribute("CaptureFromGivenWindow")]; [assembly:AssemblyDescriptionAttribute("")]; [assembly:AssemblyConfigurationAttribute("")]; [assembly:AssemblyCompanyAttribute("")]; [assembly:AssemblyProductAttribute("CaptureFromGivenWindow")]; [assembly:AssemblyCopyrightAttribute("Copyright (c) 2011")]; [assembly:AssemblyTrademarkAttribute("")]; [assembly:AssemblyCultureAttribute("")]; // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the value or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly:AssemblyVersionAttribute("1.0.*")]; [assembly:ComVisible(false)]; [assembly:CLSCompliantAttribute(true)]; [assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];

Try ByteScout Screen Capturing SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

CaptureFromGivenWindow.cpp
      
// CaptureFromGivenWindow.cpp : main project file. #include "stdafx.h" using namespace System; using namespace System::Threading; using namespace System::Diagnostics; using namespace BytescoutScreenCapturingLib; int main(array<System::String ^> ^args) { // Create Capturer instance Capturer ^capturer = gcnew Capturer(); capturer->RegistrationName = "demo"; capturer->RegistrationKey = "demo"; // Set capturing type capturer->CapturingType = CaptureAreaType::catWindow; // Specify window to capture by its title. // Capturer will take the first window containing "Internet Explorer" in its title. capturer->WindowToCapture = "Internet Explorer"; // You can also capture only a part of the window by specifying capturing rectangle //capturer->CaptureRectLeft = 25; //capturer->CaptureRectTop = 25; //capturer->CaptureRectWidth = 320; //capturer->CaptureRectHeight = 240; // WMV and WEBM output use WMVVideoBitrate property to control output video bitrate // so try to increase it by x2 or x3 times if you think the output video are you are getting is laggy // capturer->put_WMVVideoBitrate(capturer->WMVVideoBitrate * 2); // uncomment to enable recording of semitransparent or layered windows (Warning: may cause mouse cursor flickering) // capturer->CaptureTransparentControls = true; // Set output video width and height capturer->OutputWidth = 640; capturer->OutputHeight = 480; // set border style capturer.CaptureAreaBorderType = CaptureAreaBorderType::cabtDashed; // Set output file name capturer->OutputFileName = "Output.wmv"; // Start capturing capturer->Run(); // IMPORTANT: if you want to check for some code if need to stop the recording then make sure you are // using Thread.Sleep(1) inside the checking loop, so you have the loop like // Do { // Thread.Sleep(1) // } // While(StopButtonNotClicked); Console::WriteLine("Capture window for 5s..."); // Wait for 5 seconds Thread::Sleep(5000); // Stop capturing capturer->Stop(); // Release resources System::Runtime::InteropServices::Marshal::ReleaseComObject(capturer); //capturer = NULL; Console::WriteLine("Done."); // Open the capture video in default associated application Process::Start("Output.wmv"); return 0; }

Try ByteScout Screen Capturing SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

resource.h
      
//{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by app.rc

Try ByteScout Screen Capturing SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

stdafx.cpp
      
// stdafx.cpp : source file that includes just the standard includes // CaptureFromGivenWindow.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h"

Try ByteScout Screen Capturing SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

stdafx.h
      
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once // TODO: reference additional headers your program requires here

Try ByteScout Screen Capturing SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

VIDEO

ON-PREMISE VERSION INFORMATION

Get 60 Day Free Trial or Visit ByteScout Screen Capturing SDK Home Page

Explore ByteScout Screen Capturing SDK Documentation

Get ByteScout Screen Capturing SDK Free Training

WEB API

Get Your Free API Key

Explore Web API Documentation

Tutorials:

prev
next