2023-08-10 08:53:23 +00:00
|
|
|
const { BrowserWindow, app, screen, ipcMain, desktopCapturer } = require('electron')
|
2019-10-16 15:17:50 +00:00
|
|
|
|
|
|
|
let mainWindow = null
|
|
|
|
|
2020-09-14 17:36:54 +00:00
|
|
|
ipcMain.handle('get-screen-size', () => {
|
|
|
|
return screen.getPrimaryDisplay().workAreaSize
|
|
|
|
})
|
|
|
|
|
2023-08-10 08:53:23 +00:00
|
|
|
ipcMain.handle('get-sources', (event, options) => {
|
|
|
|
return desktopCapturer.getSources(options)
|
|
|
|
})
|
|
|
|
|
2019-10-16 15:17:50 +00:00
|
|
|
function createWindow () {
|
|
|
|
const windowOptions = {
|
|
|
|
width: 600,
|
|
|
|
height: 300,
|
|
|
|
title: 'Take a Screenshot',
|
|
|
|
webPreferences: {
|
2023-07-13 08:10:37 +00:00
|
|
|
contextIsolation: false,
|
2019-10-16 15:17:50 +00:00
|
|
|
nodeIntegration: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mainWindow = new BrowserWindow(windowOptions)
|
|
|
|
mainWindow.loadFile('index.html')
|
|
|
|
|
|
|
|
mainWindow.on('closed', () => {
|
|
|
|
mainWindow = null
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:43:22 +00:00
|
|
|
app.whenReady().then(() => {
|
2019-10-16 15:17:50 +00:00
|
|
|
createWindow()
|
|
|
|
})
|