-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
100 lines (84 loc) · 2.27 KB
/
Copy pathindex.js
File metadata and controls
100 lines (84 loc) · 2.27 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// index.js
import { app, BrowserWindow, globalShortcut, screen, ipcMain } from "electron";
let win = null;
let clickThrough = false;
let isVisible = false; // Start hidden, so first Ctrl+Alt+G shows the overlay
const createWindow = () => {
const { width, height } = screen.getPrimaryDisplay().size;
console.log("Creating window with dimensions:", width, "x", height);
win = new BrowserWindow({
x: 0,
y: 0,
width,
height,
frame: false,
transparent: true,
resizable: true,
alwaysOnTop: true,
skipTaskbar: true,
hasShadow: false,
backgroundColor: "#00000000",
focusable: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});
// Keep above taskbar (Windows)
win.setAlwaysOnTop(true, "screen-saver");
win.loadFile("index.html");
// Start maximized (not fullscreen, so still resizable)
win.setBounds({ x: 0, y: 0, width, height });
// Hide window on startup - user will press Ctrl+Alt+G to show it
win.hide();
console.log("Window created and hidden - press Ctrl+Alt+G to show");
};
const registerShortcuts = () => {
// Toggle overlay visibility
globalShortcut.register("Control+Alt+G", () => {
console.log("Ctrl+Alt+G pressed! Current isVisible:", isVisible);
if (!win) {
console.log("No window found!");
return;
}
isVisible = !isVisible;
console.log("Toggling visibility to:", isVisible);
if (isVisible) {
win.show();
if (!clickThrough) win.setFocusable(true);
win.setAlwaysOnTop(true, "screen-saver");
console.log("Window shown");
} else {
win.hide();
console.log("Window hidden");
}
});
// Toggle click-through mode
globalShortcut.register("Control+Alt+C", () => {
if (!win) return;
clickThrough = !clickThrough;
if (clickThrough) {
win.setIgnoreMouseEvents(true, { forward: true });
win.setFocusable(false);
} else {
win.setIgnoreMouseEvents(false);
win.setFocusable(true);
win.setAlwaysOnTop(true, "screen-saver");
win.focus();
}
});
};
app.whenReady().then(() => {
createWindow();
registerShortcuts();
// Handle quit request from renderer
ipcMain.on("quit-app", () => {
app.quit();
});
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on("will-quit", () => {
globalShortcut.unregisterAll();
});