This commit is contained in:
khlam 2019-10-11 19:52:09 -07:00
parent 99f4ed0b05
commit c3db4d4286
3 changed files with 26 additions and 7 deletions

View File

@ -4,7 +4,6 @@ html, body{
margin:0px;
padding: 0;
overflow: hidden;
background-color: green;
}
div {

12
main.js
View File

@ -1,5 +1,5 @@
// Modules to control application life and create native browser window
const {app, BrowserWindow} = require('electron')
const {app, BrowserWindow, ipcRenderer} = require('electron')
const path = require('path')
// Keep a global reference of the window object, if you don't, the window will
@ -59,11 +59,17 @@ app.on('activate', function () {
const ioHook = require('iohook');
ioHook.on('mousedown', event => {
console.log(event);
if (event.button == '4') {
console.log("mouse4 down")
mainWindow.webContents.send('ping', 'mic-open')
}
});
ioHook.on('mouseup', event => {
console.log(event);
if (event.button == '4') {
console.log("mouse4 up")
mainWindow.webContents.send('ping', 'mic-closed')
}
})
// Register and start hook
ioHook.start();

View File

@ -1,3 +1,17 @@
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
let robot = require("kbm-robot");
robot.startJar();
require('electron').ipcRenderer.on('ping', (event, message) => {
if (message === 'mic-open'){
console.log("mic is open")
robot.press("n").go()
}
if (message === 'mic-closed'){
console.log("mic is closed")
robot.release("n").go()
}
})
document.addEventListener('keydown', function (e) {
console.log('Key: ' + e.key + ' pressed');
});