Search code examples
c#.netscreen-capture

Expression Encoder 4 LiveSourceSample. how to capture secondary monitor


Im am using the sample from expression encoder 4 for capturing the monitor. This all works fine but i want to capture the secondary monitor. Does anyone know how to change this?

        // Starts new job for preview window
        job = new LiveJob();

        // Aquires audio and video devices
        Collection<EncoderDevice> devices = EncoderDevices.FindDevices(EncoderDeviceType.Video);
        EncoderDevice video = devices.Count > 0 ? devices[0] : null;
        for (int i = 1; i < devices.Count; ++i)
            devices[i].Dispose();
        devices.Clear();

        devices = EncoderDevices.FindDevices(EncoderDeviceType.Audio);
        EncoderDevice audio = devices.Count > 0 ? devices[0] : null;
        for (int i = 1; i < devices.Count; ++i)
            devices[i].Dispose();
        devices.Clear();

        // Checks for a/v devices
        if (video != null && audio != null)
        {
            // Create a new device source. We use the first audio and video devices on             the system
            deviceSource = job.AddDeviceSource(video, audio);

            // Make this source the active one

            job.ActivateSource(deviceSource);
        }
        else
        {
            error = true;
        }

Thanks

EDIT: Forgot to mention that it only finds 1 video device. ex: i cant do this

 EncoderDevice video = devices[1];

Solution

  •  deviceSource.ScreenCaptureSourceProperties = new ScreenCaptureSourceProperties()
                {
                    Left = x,
                    Top = y,
                    Width = w,
                    Height = h,
                };