Nw.js: API for get all windows

Created on 8 Apr 2014  路  9Comments  路  Source: nwjs/nw.js

Hi, I think it is convenient to have a API which can get all windows, like this:

windows = require("nw.gui").Window.getAll()
// => windows = [Window1, Window2, ...]

Using that I can track and monitor user behavior, and do some cross window operation properly.

Even though I can record the window handle after calling Window.open, Tracking opened window is a messy job for developer.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Most helpful comment

You can use chrome.app.window.getAll to get all AppWindows. If you want to get corresponding nw.Window, use nw.Window.get(appWindow.contentWindow).

All 9 comments

Hi, you can iterate from here.. global.__nwWindowsStore

@triplekdev Thanks! Looks like it not in the wiki, maybe not stable?

@halida, No idea :) i think I found that on earliest versions of node-webkit.

@triplekdev I donot know how to use global.__nwWindowsStore,eighter...Though I found it in src/api/window/window.js.

This should be working with latest version now.

In 0.13 we changed to an optimized architecture so more features can be supported, see http://nwjs.io/blog/whats-new-in-0.13/ and it's good for keeping up with Chromium upstream -- we released with Node.js v6.0 and new Chromium versions within 1 day after upstream release.

The new version would fixed many issues reported here and we're scrubbing them. This issue is closed as we believe it should be fixed. Please leave a message if it isn't and we'll reopen it.

@nwjs-bot, I just tryed to update a app to 0.16 now and "global.__nwWindowsStore" didnt works...

I found "__nw_windows" but it's not the same... How get all windows now?

You can use chrome.app.window.getAll to get all AppWindows. If you want to get corresponding nw.Window, use nw.Window.get(appWindow.contentWindow).

@ghostoy, thks very much!

if you are using "new_instance: true" while opening new window then
chrome.app.window.getAll fails

try this

chrome.windows.getAll({populate: true}, function(wins){
console.log("windows", wins)
})

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xzh-loop picture xzh-loop  路  3Comments

chino23 picture chino23  路  3Comments

rumax picture rumax  路  4Comments

hooker99 picture hooker99  路  4Comments

jportoles picture jportoles  路  3Comments