octalmage / active-window

Get active window title in Node.js.
160 stars 51 forks source link

how to get activeWindow one more times #26

Open hnlinzhi19 opened 6 years ago

hnlinzhi19 commented 6 years ago

I have a problem, I want to get now active window when i press some keys。so first i press key ,I can get the active window,but second press back throw stderr.toString(); this is my code : `'use strict'; const ioHook = require('iohook'); const monitor = require('active-window');

ioHook.on("keydown", event => { console.log(event); / You get object like this { type: 'mousemove', x: 700, y: 400 } / if (event.keycode === 67 && event.rawcode === 120) { monitor.getActiveWindow(() => { try { console.log("App: " + window.app); console.log("Title: " + window.title); }catch(err) { console.log(err); } }); } });

//Register and start hook ioHook.start();

`

the errors : throw stderr.toString();

zhaolewen commented 6 years ago

I have this problem as well and now I've changed to active-win, it can also give me the window without using a callback.