show tray in taskbar windows 10 electronjs

704 Views Asked by At

I'm using system tray of electron but when I start my app the tray hide in the dropdow of the taskbar like this image :

(icon with S)

tray in dropdown

I want the tray apear like this :

enter image description here

2

There are 2 best solutions below

0
Dai On

Windows hides icons in the notification area (its not called "the tray") because in the past (Windows 95 through Windows Vista) too many programs arrogantly thought they were important enough that the user should always see them there - which leads to noisy and cluttered examples like this:

enter image description here

To prevent this from happening and degrading the user-experience, since Windows 7 programs cannot (feasibly) promote themselves out of the "More icons..." window.

What you should do instead is give your users instructions on how they can tell Windows to keep an icon visible (Settings > Personalization > Taskbar > "Select which icons appear on the taskbar") themselves. But you cannot do it yourself in program code: there is no (public and documented) API for controlling this for the reasons I described above.

1
Carson On

Try api/tray

const electron = require("electron")
const app = electron.app
function createTray() {
  const tray = new electron.Tray( __dirname + 'Myfavicon.ico')
  const contextMenu = electron.Menu.buildFromTemplate([
    { label: 'Item1', type: 'radio' },
    { label: 'Item2', type: 'radio' },
    { label: 'Item3', type: 'radio', checked: true },
    { label: 'Item4', type: 'radio' }
  ])
  tray.setToolTip('This is my application.')
  tray.setContextMenu(contextMenu)
}

app.on("ready", createTray)