Created
May 17, 2024 09:30
-
-
Save NykoKar/f3f8e7eaec0e980d42d53c1b050e378b to your computer and use it in GitHub Desktop.
Open BrowserWindow on secondary screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { app, BrowserWindow, screen } = require('electron') | |
let win | |
app.whenReady().then(() => { | |
const displays = screen.getAllDisplays() | |
const externalDisplay = displays.find((display) => { | |
return display.bounds.x !== 0 || display.bounds.y !== 0 | |
}) | |
if (externalDisplay) { | |
win = new BrowserWindow({ | |
x: externalDisplay.bounds.x + 50, | |
y: externalDisplay.bounds.y + 50 | |
}) | |
win.loadURL('https://github.com') | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment