How do I put an app to run in the background when it’s closed?

Asked

Viewed 202 times

1

I am creating an application in Node.Js using Electron and I need it to continue running in the background when it is closed and turn into an app icon next to the computer clock for the user to have access. However I did not find references to do this task, so the question is:

How to put an app to run in the background when closed?

1 answer

2


Just set the event close of the object BrowserWindow so that it hides the application instead of closing it:

let win = new BrowserWindow({
    width: 380,
    height: 600,
  })

 win.on('close', event => {
    event.preventDefault()
    win.hide()
 })

More information here.

  • Excellent. Have any idea how to place an application icon next to the taskbar clock?

  • Take a look at the class Tray, you can pass the path to the image that will be used as icon by instantiating it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.