mirror of
https://github.com/danbulant/arcade-machine
synced 2026-06-17 05:21:23 +00:00
Can now kill game exe with globalshortcut
This commit is contained in:
parent
cc59ade8b6
commit
3e4a7335ea
3 changed files with 61 additions and 28 deletions
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
//Paths
|
||||
var AsphyxiaPath = "C:\\Users\\kryvas\\Downloads\\asphyxia-core-win-x64\\asphyxia.exe"
|
||||
var SDVX3Path = "C:\\sdvx\\spice2.lnk"
|
||||
|
|
@ -10,5 +11,8 @@ var KeyDown = "KeyS"
|
|||
var KeyLeft = "KeyA"
|
||||
var KeyRight = "KeyD"
|
||||
var KeyStart = "KeyE"
|
||||
var ExitKey1 = "g" // Only add lowercase name of the key without "Key" part example: "KeyA" becomes "a"
|
||||
var ExitKey2 = "h" // Only add lowercase name of the key without "Key" part example: "KeyA" becomes "a"
|
||||
var ExitKey1 = "G" // Only add uppercase name of the key without "Key" part example: "KeyA" becomes "A"
|
||||
var ExitKey2 = "H" // Only add uppercase name of the key without "Key" part example: "KeyA" becomes "A"
|
||||
|
||||
if(module) // kdyz to neimportujes pres require tak module bude undefined
|
||||
module.exports = { ExitKey1, ExitKey2 };
|
||||
|
|
|
|||
|
|
@ -43,17 +43,17 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
const prvnihra = [...document.querySelectorAll("button")] //creates array from buttons for focus select
|
||||
console.log(prvnihra[0])
|
||||
console.log(prvnihra[0])
|
||||
prvnihra[0].focus();
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
//SFX Audio Sources
|
||||
var i = 0;
|
||||
const switchfocus = new Audio("Audio/switchfocus.mp3");
|
||||
var i = 0;
|
||||
const switchfocus = new Audio("Audio/switchfocus.mp3");
|
||||
const startaudio = new Audio("Audio/audiostart.mp3")
|
||||
/* Handles interaction with bindable buttons and focus*/
|
||||
document.addEventListener("keydown", function (KeypressD) {
|
||||
|
|
@ -94,53 +94,50 @@
|
|||
}
|
||||
//document.body.requestFullscreen();
|
||||
})
|
||||
|
||||
let keysPressed = {};
|
||||
document.addEventListener('keydown', (event) => {
|
||||
keysPressed[event.key] = true;
|
||||
|
||||
if (keysPressed[ExitKey1] && event.key == ExitKey2) {
|
||||
alert(event.key);
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('keyup', (event) => {
|
||||
delete keysPressed[event.key];
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
var vers = 0;
|
||||
const { execFile, exec, spawn } = require('child_process');
|
||||
function sdvx() {
|
||||
console.log("promenna", vers);
|
||||
const { ipcRenderer } = require('electron');
|
||||
/* Handles Running of apps */
|
||||
switch (vers) {
|
||||
case 3:
|
||||
Execounter = 1;
|
||||
execFile(AsphyxiaPath);
|
||||
exec("start /b " + SDVX3Path); //executes cmd with start and path
|
||||
setTimeout(function () {
|
||||
exec("taskkill /im " + browser)//kills browser
|
||||
}, 2000)
|
||||
//console.log(vers);
|
||||
ipcRenderer.send("number", Execounter); //sends number to main which tells main what to kill on shortcut
|
||||
break;
|
||||
case 4:
|
||||
Execounter = 2;
|
||||
execFile(AsphyxiaPath);
|
||||
exec("start /b " + SDVX4Path);
|
||||
setTimeout(function () {
|
||||
exec("taskkill /im " + browser)
|
||||
}, 1200)
|
||||
ipcRenderer.send("number", Execounter);
|
||||
break;
|
||||
case 5:
|
||||
Execounter = 3;
|
||||
|
||||
execFile(AsphyxiaPath);
|
||||
exec("start /b " + SDVX5Path);
|
||||
setTimeout(function () {
|
||||
exec("taskkill /im " + browser)
|
||||
}, 1200)
|
||||
ipcRenderer.send("number", Execounter);
|
||||
break;
|
||||
case 6:
|
||||
|
||||
|
|
|
|||
42
ui/main.js
42
ui/main.js
|
|
@ -1,7 +1,12 @@
|
|||
const { app, BrowserWindow } = require('electron');
|
||||
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||
const { globalShortcut } = require('electron');
|
||||
const createWindow = () => {
|
||||
// Create the browser window.
|
||||
ipcMain.on("number",(event,data)=>{ //Reads number var from index
|
||||
console.warn(data)
|
||||
Execounter = data;
|
||||
console.warn(Execounter)
|
||||
})
|
||||
// Create the browser window.
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
|
|
@ -12,12 +17,39 @@ const createWindow = () => {
|
|||
},
|
||||
autoHideMenuBar: true
|
||||
});
|
||||
mainWindow.loadFile("index.html") //loadne index.html
|
||||
mainWindow.loadFile("index.html") //loads index.html
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
createWindow();
|
||||
|
||||
const { ExitKey1, ExitKey2 } = require("./Vars.js") //imports exitkeys from vars.js
|
||||
const { execFile, exec, spawn } = require('child_process');
|
||||
console.log(ExitKey1 + " + " + ExitKey2);
|
||||
|
||||
const ret = globalShortcut.register(ExitKey1 + " + " + ExitKey2, () => { //makes globalshortcut from vars in vars.js
|
||||
console.log('CommandOrControl+X is pressed')
|
||||
});
|
||||
//On shortcut kills game exe
|
||||
switch(Execounter){
|
||||
case 1:
|
||||
console.warn("funguje" + Execounter);
|
||||
exec("taskkill /im spice.exe")
|
||||
break;
|
||||
case 2:
|
||||
console.warn("funguje" + Execounter);
|
||||
exec("taskkill /im spice.exe")
|
||||
break;
|
||||
case 3:
|
||||
console.warn("funguje" + Execounter);
|
||||
exec("taskkill /im spice.exe")
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue