-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
87 lines (75 loc) 路 2.49 KB
/
Copy pathmain.js
File metadata and controls
87 lines (75 loc) 路 2.49 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
const { app, Menu, Tray, BrowserWindow, globalShortcut, ipcMain, desktopCapturer } = require('electron')
const {spawn, exec} = require("node:child_process")
const util = require('node:util');
const execPromise = util.promisify(require('node:child_process').exec);
let win = null
const createWindow = () => {
win = new BrowserWindow({
fullscreen: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
},
transparent: true,
frame: false,
resizable: false,
alwaysOnTop: true,
icon: __dirname + "\\src\\assets\\icons\\guidenite.png"
})
win.setAlwaysOnTop(true, 'screen-saver');
win.setVisibleOnAllWorkspaces(true)
win.setMinimizable(false);
win.loadFile('index.html')
win.on('show', () => {
setTimeout(() => {
win.focus();
}, 100);
});
}
app.whenReady().then(() => {
createWindow();
})
let homeButtonCommand = __dirname + "\\button_on_360_guide_v5\\listener.exe"
let homeButtonChild = spawn(homeButtonCommand, {windowsHide: false});
homeButtonChild.stdout.setEncoding('utf8')
homeButtonChild.stdout.on("data", async function(){
const { stdout: openWindowsStdout, stderr: openWindowsErr } = await execPromise('powershell ./shell/listOpenWindows.ps1');
const ignoredWindows = [
"Guidenite",
"Microsoft Text Input Application",
"explorer",
"Taskmgr",
"Code",
"powershell"
]
if(win.isVisible()){
win.blur()
win.hide()
resumeBackgroundWindows(JSON.parse(openWindowsStdout), ignoredWindows)
}else{
suspendBackgroundWindows(JSON.parse(openWindowsStdout), ignoredWindows)
win.show()
}
})
function suspendBackgroundWindows(openWindows = [], ignoredWindows) {
openWindows.forEach(window=>{
if(
!ignoredWindows.includes(window.MainWindowTitle)
&& !ignoredWindows.includes(window.Description)
&& !ignoredWindows.includes(window.Name)
){
exec("powershell ./PSTools/pssuspend.exe " + window.Id)
}
})
}
function resumeBackgroundWindows(openWindows, ignoredWindows) {
openWindows.forEach(window=>{
if(
!ignoredWindows.includes(window.MainWindowTitle)
&& !ignoredWindows.includes(window.Description)
&& !ignoredWindows.includes(window.Name)
){
exec("powershell ./PSTools/pssuspend.exe -r " + window.Id)
}
})
}