屏幕记录单个窗口

时间:2011-11-26 19:34:50

标签: c# sdk screen-capture

我正在寻找能够录制特定窗口(hwnd)的SDK,插件或代码。 如果可能的话,用C#或Java。有谁知道这是否存在?我一直在谷歌搜索,但没有遇到任何事情。

1 个答案:

答案 0 :(得分:4)

安装Microsoft Expression Encoder 4 with Service Pack 2 (SP2)

这是一个使用它的示例程序。 SDK中附带了一个更全面的示例,该示例包含在下载中。

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();
        }
    }
}