-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
57 lines (49 loc) · 1.55 KB
/
main.js
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
const { app, BrowserWindow, screen } = require('electron')
const path = require('path')
interval = undefined;
app.allowRendererProcessReuse = false
function createWindow() {
const win = new BrowserWindow({
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
preload: path.join(__dirname, 'preload.js')
},
frame: false,
transparent: true,
minimizable: false,
alwaysOnTop: true,
hasShadow: false,
})
win.loadFile('index.html')
if (process.platform == "darwin")
win.setIgnoreMouseEvents(false)
else
win.setIgnoreMouseEvents(true, { forward: true })
win.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
win.setAlwaysOnTop(true, process.platform == "darwin" ? "floating" : "normal", 1);
win.setFullScreenable(false);
win.maximize()
if (process.platform == "darwin") app.dock.show()
interval = setInterval(() => {
var mousepos = screen.getCursorScreenPoint()
if (process.platform == "darwin") mousepos.x -= 8;
if (process.platform == "darwin") mousepos.y -= 36;
if (open)
win.webContents.send('mouse', mousepos);
}, 33);
}
app.on('window-all-closed', function () {
app.quit()
open = false;
clearInterval(interval)
})
app.whenReady().then(() => {
createWindow()
open = true
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0)
createWindow()
})
})