From c3db4d4286a80021212df6d94c6e03ba0a92b2d9 Mon Sep 17 00:00:00 2001 From: khlam <4841220+khlam@users.noreply.github.com> Date: Fri, 11 Oct 2019 19:52:09 -0700 Subject: [PATCH] testing --- css/style.css | 1 - main.js | 12 +++++++++--- renderer.js | 20 +++++++++++++++++--- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/css/style.css b/css/style.css index 513e133..7dae1a3 100644 --- a/css/style.css +++ b/css/style.css @@ -4,7 +4,6 @@ html, body{ margin:0px; padding: 0; overflow: hidden; - background-color: green; } div { diff --git a/main.js b/main.js index 3a5be6f..9f53f88 100644 --- a/main.js +++ b/main.js @@ -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(); diff --git a/renderer.js b/renderer.js index 901d75e..6b63ab3 100644 --- a/renderer.js +++ b/renderer.js @@ -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'); +}); \ No newline at end of file