Hot to get opened window count in an Electron app?

Viewed 9244

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?

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

Related