Windows

Streamlining Electron.js App with Tray Icons

In the realm of desktop application development, Electron.js stands out as a robust framework for building cross-platform apps using web technologies. Among its many features, integrating tray icons can significantly enhance user experience by providing quick access to essential functionalities. Today, let’s explore how we can implement tray icons in our Electron.js application, from setup to implementation.

Setting Up A Electron.js Project

First things first, let’s set up a basic Electron.js project:

1. Initialize a new Node.js project

mkdir project_name && cd project_name
npm init -y

2. Install Electron.js

npm install electron

3. Create project files

project_name/
├── icon.png
├── index.html
├── index.js
├── node_modules
├── package.json
└── package-lock.json

– `index.html` for the application’s UI.

– `index.js` for Electron main process code.

– An icon file (`icon.png`) for the tray icon.

– add `start` command in package.json like this.

{
  "name": "project_name",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "electron ."
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "electron": "^29.0.1"
  }
}

Implementing Tray Icon Functionality

Next, let’s dive into implementing the tray icon functionality in `index.js` file:

const { app, Tray, BrowserWindow } = require('electron');
const path = require('path');

let tray = null;
let mainWindow = null;

app.on('ready', () => {
  tray = new Tray(path.join(__dirname, 'icon.png'));

  mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    show: false,
    webPreferences: {
      nodeIntegration: true
    }
  });

  mainWindow.loadFile('index.html');

  tray.on('click', () => {
    mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
  });
});

Running Your Electron.js Application

To run Electron.js application, execute the following command in the terminal:

npm start

This command will start Electron application, and we should see the tray icon appear in our system tray. Clicking on the tray icon should toggle the visibility of the application window.

Conclusion

Integrating tray icons into Electron.js application is a straightforward process that can greatly improve user experience. Whether it’s for displaying notifications, providing quick access to features, or simply adding a professional touch to our app, tray icons are a valuable addition to any desktop application.

With Electron.js, implementing tray icons becomes seamless, allowing us to focus on crafting an exceptional user experience for our desktop application. So why not enhance our Electron.js app with a sleek tray icon for innovative ideas?

Hope you enjoy that.

By Asahi



netshコマンドを利用した簡単なポートフォワードの設定方法

Dockerで建てたローカルネットワーク内の仮想サーバーにポート番号を指定せずに
URLでアクセスしたいことがありましたので、その方法を調べました。

続きを読む

DuckDuckGo releases it’s window version browser

DuckDuckGo’s privacy-focused browser is now available for Windows users. The Windows release comes nine months after the browser’s public release for Mac users, and the Windows browser, now in public beta, includes many of the same privacy protections as the iOS version, Mac and Android browsers. I’m here.

Users can first import passwords and bookmarks from another browser or password manager. This browser does not yet support extensions, seems to be available in the near future.

The browser includes its own password manager that can remember and auto-fill your login credentials. DuckDuckGo for Windows can now suggest strong passwords for new logins. The company says the feature will become even more useful once it launches private cross-device sync, allowing users to sync their saved bookmarks and passwords across different devices.

Image Credit : DuckDuckGo

The browser includes Duck Player. This is an embedded video player designed to protect her from tracking cookies and targeted ads when a user watches his YouTube. The company notes that YouTube still tracks video views, so users aren’t completely anonymous, but none of the videos they watch on Duck Player contribute to personalized recommendations or his YouTube advertising profile. said. You can leave this feature on all the time or join individual videos.

DuckDuckGo says it is working to bring its Windows browser on par with its Mac browser, including improvements such as faster launch performance, pinned tabs, HTML bookmark import, and additional fire button options. You can see more detail relating with this launch here.

Yuuma



Stable Diffusion WebUI(Automatic1111)を試してみました

Stable DiffusionをローカルPCで比較的簡単に実行することができる
Stable Diffusion WebUI(Automatic1111)を試してみました。

続きを読む

Windows用の Direct Storage API がリリースされました

XBOX series X では既に利用されていますが、
約1年程遅れてWindowsでも利用可能になるようです。

続きを読む


アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム