Get the main window object of an Electron Application.
1 min readFeb 5, 2019
- Author: Ganesh Rathinavel
- License: MIT
- Repo URL: https://github.com/ganeshrvel/npm-electron-main-window
- Contacts: ganeshrvel@outlook.com
Introduction
Get the main window object of an Electron Application.
Finding the main window of an electron app could become tricky, this NPM package helps you with the same
Initially, I created the “electron-main-window” NPM package as an internal utility for OpenMTP — Advanced Android File Transfer Application for macOS. It works well with the Electron React Redux Advanced Boilerplate and electron-react-boilerplate.
Installation
$ npm install electron-main-windowor $ yarn add electron-main-window
Usage
// Import ES6 way
import { getMainWindow } from 'electron-main-window';
const mainWindow = getMainWindow();// Import ES2015 way
const mainWindow = require('electron-main-window').getMainWindow();// e.g:
if(mainWindow !== null ){
mainWindow.webContents.send('mainWindowCommunication', "This is a test message");
}
More repos
- Electron React Redux Advanced Boilerplate
- OpenMTP — Advanced Android File Transfer Application for macOS
- Tutorial Series by Ganesh Rathinavel
License
electron-main-window | Get the main window of an Electron Application is released under MIT License.
Copyright © 2018-Present Ganesh Rathinavel