Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { app, BrowserWindow, ipcMain } = require('electron');
- const activeWindows = require('electron-active-window');
- let win;
- function createWindow() {
- win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true, contextIsolation: false } });
- win.loadURL('http://localhost:4200');
- win.on('closed', () => {
- win = null;
- });
- }
- function sendActiveWindows() {
- activeWindows().getActiveWindow().then((result) => {
- win.webContents.send("get-active-window-reply", result)
- });
- }
- app.on('ready', createWindow);
- app.on('window-all-closed', () => {
- if (process.platform !== 'darwin') {
- app.quit();
- }
- });
- app.on('activate', () => {
- if (win === null) {
- createWindow();
- }
- });
- app.on('browser-window-created', (_event, _arg) => {
- sendActiveWindows();
- });
- ipcMain.on('get-active-window', (_event, _arg) => {
- sendActiveWindows();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement