2.0.3 • Published 2 years ago

electray v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

npm version npm bundle size npm downloads GitHub last commit \ platform npm dev dependency version node-current

Electray

Full support for tray notify icon of Windows Shell on Electron

Installation

You can install Electray using npm:

npm install electray

Example

Electray is very simple to use:

Typescript:

import * as electron from 'electron';
import * as electray from 'electray';
electron.app.on("ready", (event, launchInfo) => {
    let window: electron.BrowserWindow = new electron.BrowserWindow({
        width: 1024,
        height: 768
    });
    let tray: electray.Electray = new electray.Electray({
        window: window,
        icon: "default",
        showIcon: true,
        tips: "This is a Electray icon",
        showTips: true
    });
    tray.on('Select', (x, y) => {
        tray.showBalloon({
            title: `title`,
            information: `information`,
            icon: `info`,
            timeoutMilliSeconds: 15000
        });
    });
    window.on('close', (event) => {
        tray.showIcon = false;
    });
    window.loadURL(`http://www.baidu.com`);
});
electron.app.on("window-all-closed", () => {
    process.exit();
});

Javascript:

const electron = require('electron');
const electray = require('electray');
electron.app.on("ready", (event, launchInfo) => {
    let window = new electron.BrowserWindow({
        width: 1024,
        height: 768
    });
    let tray = new electray.Electray({
        window: window,
        icon: "default",
        showIcon: true,
        tips: "This is a Electray icon",
        showTips: true
    });
    tray.on('Select', (x, y) => {
        tray.showBalloon({
            title: `title`,
            information: `information`,
            icon: `info`,
            timeoutMilliSeconds: 15000
        });
    });
    window.on('close', (event) => {
        tray.showIcon = false;
    });
    window.loadURL(`http://www.baidu.com`);
});
electron.app.on("window-all-closed", () => {
    process.exit();
});

Properties

showTips

Specifics whether the tips will be show or not when user cursor stay at the icon.

tips

Tips content to popup when user cursor stay at the icon.

  • PopupOpen and PopupClose event can be trigger only if tips has been set.

showIcon

Specifics whether the icon will be show or not.

icon

Icon use of notify icon tray.

Values of icon:

Valuenote
'none'Empty icon.
'default'Windows system default application icon.
'window'Use icon of window from construction options, this window must has icon settled.
BufferA buffer has a .ico file inside.

Methods

Methodnote
showBalloonPopup a balloon to show message.

Events

Eventparamsnote
Selectx, yMouse click select tray icon.
KeySelectx, yKeyboard select tray icon
ContextMenux, yMouse right click on icon or context menu key pressed
--
PopupOpenx, yPopup tips when cursor stay at notify tray icon. This event can be trigger only if tips has been set.
PopupClose-Popup tips closed.
--
BalloonShowx, y
BalloonHidex, yWhen does this event will be trigger is a mystery
BalloonTimeoutx, y
BalloonUserClickx, y
--
MouseMovex, y
MouseLeftButtonDownx, y
MouseLeftButtonUpx, y
MouseLeftButtonDoubleClickx, y
MouseRightButtonDownx, y
MouseRightButtonUpx, y
MouseRightButtonDoubleClickx, y
MouseMiddleButtonDownx, y
MouseMiddleButtonUpx, y
MouseMiddleButtonDoubleClickx, y

devDependencies

  • @types/node
  • electron

Remarks

Electray has pre-build both ia32 and x64 binaries of Windows native Node.JS add-on module, it will auto detect the arch you need and copy 2 files during postinstall, If you got problems with arch, you can simplely re-install Electray.

Links