-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
38 lines (30 loc) · 1022 Bytes
/
Copy pathmain.js
File metadata and controls
38 lines (30 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { app, BrowserWindow, globalShortcut } = require('electron');
const { exec } = require('child_process');
let win;
app.whenReady().then(() => {
win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: { nodeIntegration: false }
});
win.loadURL('http://localhost:3000');
// Start the Express server
exec('node server.js', (error, stdout, stderr) => {
if (error) console.error(`Error: ${error.message}`);
if (stderr) console.error(`Stderr: ${stderr}`);
console.log(`Server Output: ${stdout}`);
});
// Global Hotkeys
globalShortcut.register('Control+Alt+S', () => {
console.log('Start/Stop hotkey pressed');
win.webContents.send('hotkey', 'startStop');
});
globalShortcut.register('Control+Alt+R', () => {
console.log('Reset hotkey pressed');
win.webContents.send('hotkey', 'reset');
});
console.log('Hotkeys Registered: CTRL+ALT+S (Start/Stop), CTRL+ALT+R (Reset)');
});
app.on('will-quit', () => {
globalShortcut.unregisterAll();
});