Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hot to get opened window count in an Electron app?

Tags:

electron

Is there any API provided by Electron to let get the current opened BrowserWindow count?

I did not find the method via the app API. Or can I get how many renderProcess is running now?

like image 258
Chris Avatar asked Nov 26 '17 05:11

Chris


People also ask

What is Kiosk mode Electron?

Kiosk mode is a common way to lock down a Windows device when that device is used for a specific task or used in a public setting. So in electron kiosk mode, we'd have the ability to lock down our application to a point that users are restricted to the actions that we want them to perform.

Will quit vs before quit?

The before-quit event will be emitted first. If all windows are successfully closed, the will-quit event will be emitted and by default the application will terminate.

How do you determine the size of an Electron window?

Size of the window: The default size of an Electron window is 800*800. We can change this size by passing a few values in the BrowserWindow constructor. 1 2 3 4 5 6 7 const createWindow = () => { win = new BrowserWindow({ width: 800, height: 500 }); win. loadFile("index.

How do I check my Electron app?

Start recording a test by going to Test > Record > Record Keyword Test. Expand the Recording toolbar, click Run App, and then select the Electron application. Create Property Checkpoints by clicking Add Check. Checkpoints verify objects and values in the application that's being tested.


1 Answers

You can use BrowserWindow.getAllWindows and use isVisible per instance optionally:

  let count = BrowserWindow.getAllWindows()
  .filter(b => {
    return b.isVisible()
  })
  .length

For number of renderer processes (which is not necessarily the same as BrowserWindow count) you can use webContents.getAllWebContents()

like image 180
pergy Avatar answered Sep 19 '22 04:09

pergy