Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screen record a single window

I'm looking for a SDK, plugin or code that will videorecord a specific window (hwnd). If possible in C# or Java. Does anyone know if this exists? I've been googling, but haven't come across anything.

like image 315
Jochen Avatar asked Nov 26 '11 19:11

Jochen


People also ask

How do I record just one part of my screen?

First of all, you need to install a screen recorder that supports choosing the recording region freely. Then, launch the recording software on your computer and select the recording area in the screen recording mode. After you adjust the settings, click on the "REC" button to start recording your screen.


1 Answers

Install Microsoft Expression Encoder 4 with Service Pack 2 (SP2).

Here's a sample program to use it. A fuller sample comes with the SDK, which is included in the download.

using System;
using System.Drawing;
using Microsoft.Expression.Encoder.ScreenCapture;

// Added references to:
// Microsoft.Expression.Encoder
// Microsoft.Expression.Encoder.Types
// Microsoft.Expression.Encoder.Utilities
// WindowsBase
// System.Drawing (for Rectangle)

namespace scrcap
{
    class Program
    {
        static void Main(string[] args)
        {
            ScreenCaptureJob job = new ScreenCaptureJob();

            // You can capture a window by setting its coordinates here
            job.CaptureRectangle = new Rectangle(100, 100, 200, 200);

            // Include the mouse pointer in the captured video
            job.CaptureMouseCursor = true;

            // Output file; you can transcode the xesc file to something else later.
            // Note that this silently does nothing if the file already exists.
            job.OutputScreenCaptureFileName = @"C:\Users\arx\scrcap\capture.xesc";

            // Do some capture
            job.Start();
            // Wait for a keypress
            Console.ReadKey();
            // And stop
            job.Stop();
        }
    }
}
like image 103
arx Avatar answered Oct 09 '22 13:10

arx