Screen Sharing
  • Electron : JavaScript
  • Windows
  • SDK Downloads
  • Sample Codes
  • Quick Starts
  • Documentation
  • Screen Sharing
  • Quick Starts
  • Sharing Selected Window

Sharing Selected Window

Last updated:2022-03-22 13:06

1 Introduction

The window sharing function refers to selecting a window as the collection target and performing data collection, and pushing the collected data out. This article mainly describes how to perform window collection.

2 Collection and Call Flow

2.1 Get the Window List

Calling the enumWindowList interface will return an array containing window list information.

let windowList = zgScreenCapture.enumWindowList()
console.log("windowList: ", windowList)

The prototype of each window object is as follows.

interface IZegoExpressPluginScreenCaptureWindowItem {
    /**
     * identification for the window
     */
    handle: any,

    /**
     * window title
     */
    title: string,
}

2.2 Set Collection Target

When calling the setTargetWindow interface, pass in the handle of a window and set the window as the collection target.

// If you select the first window
let theTargetWindow = windowList[0]

// Pass in the handle of the selected window to setTargetWindow
zgScreenCapture.setTargetWindow(theTargetWindow.handle);

2.3 Start Collecting

Call the startCapture interface to start window capture. Before starting the acquisition, you can set the window acquisition frame rate, whether to capture the cursor and other information at the same time.

// Set the acquisition frame rate,
// The default acquisition frame rate is 5fps, it is recommended to keep the frame rate low
zgScreenCapture.setFPS(5);

// Set whether to capture the cursor at the same time
zgScreeCapture.setCursorVisible(visible=true);

// Set whether to display the click animation while capturing the sharing screen
zgScreeCaptureenableClickAnimation(enable=false);

// start collection
zgScreeCapture.startCapture();
Page Directory