-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
68 lines (54 loc) · 1.71 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
58
59
60
61
62
63
64
65
66
67
68
const { app, BrowserWindow, Menu } = require('electron')
const electron = require('electron')
const path = require('path');
const robot = require('robotjs');
const { exec } = require('child_process');
const { ipcMain } = require('electron');
require('electron-reload')(__dirname);
let mainWindow
function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
resizable: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: true,
enableRemoteModule: true,
preload: path.join(__dirname, 'preload.js'),
}
})
mainWindow.loadFile('index.html')
// Remove the toolbar
Menu.setApplicationMenu(null)
mainWindow.on('closed', function () {
mainWindow = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (mainWindow === null) {
createWindow()
}
})
//launch
ipcMain.on('launch-and-login', (event, { username, password }) => {
const leaguePath = "C:\\Riot Games\\League of Legends\\LeagueClient.exe";
exec(`"${leaguePath}"`, (error) => {
if (error) {
console.error(`Error launching League of Legends: ${error}`);
return;
}
});
setTimeout(() => {
robot.typeStringDelayed(username, 100000); //100000 characters per minute, but it seemes to be capped
robot.keyTap("tab"); // Move to the password input field
robot.typeStringDelayed(password, 100000);
robot.keyTap("enter"); // Press Enter to log in
}, 5000); // 5 second delay to allow League to load
});