SnosMe / electron-overlay-window

Creating overlays is easy like never before
MIT License
200 stars 37 forks source link

Keep event keyboard on overlay blur #38

Closed LucasColomer closed 1 year ago

LucasColomer commented 1 year ago

Hello, I'm trying to create an overlay to track a user's actions.

I'm using the following code in the overlay html code to track mouse movements: document.addEventListener('mousemove', (e) => { console.log(e); });

For the keyboard, I use the following code: document.addEventListener('keydown', (e) => { console.log(e); });

When the overlay is not in focus, none of the codes work. By modifying the code a little, in particular by adding the { forward: true } option in the code when calling the setIgnoreMouseEvents function, I get the mouse movement.

However, for keyboard actions, if the overlay is not focused, I get no result.

Can anyone think of a way to retrieve keyboard inputs even if the overlay isn't focused?

SnosMe commented 1 year ago

Obviously only the event loop of focused window receives inputs from OS. So you need a hacky way to hook into global events, look into uiohook-napi package

LucasColomer commented 1 year ago

Yes, clearly, I was wondering if it was possible to get the inputs directly from the C files and send them back to electron.

I've started looking at the uiohook-napi package and I'm going to continue on this path.

Thanks for the reply

LucasColomer commented 1 year ago

The uiohook-napi work perfectly, thx for the work and have a good day !