How reach window from NWJS background script?

884 views Asked by At

I am loading a background script in NWJS with the following manifest file:

{
    "name": "Testing background process",
    "main": "index.js",
    "bg-script" : "bg.js"
}

From the background script, I want to access the window, so I'm trying:

let win = nw.Window.get()
console.log(win)

But that gives the following error:

Uncaught cannot get current window; are you in background page/node context?

How can I find the window from a background script? My goal is to listen to events in the current window.

1

There are 1 answers

0
lsabi On

I know it's late, but instead of bg-script use node-main