using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows;
using Microsoft.Expression.Encoder;
using Microsoft.Expression.Encoder.Devices;
using Microsoft.Expression.Encoder.ScreenCapture;
namespace WindowsFormsApplication4
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
ScreenCaptureJob job = new ScreenCaptureJob();
private void button1_Click(object sender, EventArgs e)
{
//// You can capture a window by setting its coordinates here
//job.CaptureRectangle = new Rectangle(0, 0, SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height);
//// Include the mouse pointer in the captured video
//job.CaptureMouseCursor = true;
//System.IO.File.Delete(@"D:\capture.xesc");
//// 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 = @"D:\capture.xesc";
//// Do some capture
//job.Start();
// And stop
job.CaptureRectangle = new Rectangle(0, 0, SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height);
job.ScreenCaptureVideoProfile.Size = new Size(SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height); //By doing this Is it supposed to resize original size to 600x400 pixels?
job.ScreenCaptureVideoProfile.AutoFit = true;
job.ShowFlashingBoundary = false;
job.ScreenCaptureVideoProfile.FrameRate = 20;
job.CaptureMouseCursor = true;
job.ScreenCaptureVideoProfile.SmoothStreaming = true;
job.ScreenCaptureVideoProfile.Quality = 20;
foreach(EncoderDevice eda in EncoderDevices.FindDevices(EncoderDeviceType.Audio))
{
job.AddAudioDeviceSource(eda);
}
System.IO.File.Delete(@ "D:\test.wmv");
job.OutputScreenCaptureFileName = string.Format(@ "D:\test.wmv");
// Do some capture
job.Start();
// And stop
}
private void j_EncodeProgress(object sender, EncodeProgressEventArgs e)
{}
private void button2_Click(object sender, EventArgs e)
{
string path = job.OutputScreenCaptureFileName;
job.Stop();
}
private void button3_Click(object sender, EventArgs e)
{}
private void button3_Click_1(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = @ "D:\test.wmv";
}
}
}This code snippet for Desktop Activity Recording.