electron

Remote function - use Electron functions in JavaScript

Introduction#

If you have to change some things in renderer.js or main.js but you want to do the changes in index.html, you can use the remote function. It lets you access all the electron functions you need!

Syntax#

  • use remote like require("electron"):
    • main.js:    const electron = require("electron");

      index.html: const electron = require("electron").remote;

Using remote by setting the progress bar

const { remote } = require("electron"); // <- The Node.js require() function is
                                      // added to JavaScript by electron

function setProgress(p) { // p = number from 0 to 1
  const currentWindow = remote.getCurrentWindow();
  currentWindow.setProgressBar(p);
}

Using remote by setting window to fullscreen

const { remote } = require("electron"); // <- The Node.js require() function is
                                      // added to JavaScript by electron

function fullscreen(f) { // p = false or true
  const currentWindow = remote.getCurrentWindow();
  currentWindow.maximize();
}

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow