Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win10/Electron - UiohookKeyboardEvent Hook failing to call. #54

Open
kered59 opened this issue Nov 8, 2024 · 3 comments
Open

Win10/Electron - UiohookKeyboardEvent Hook failing to call. #54

kered59 opened this issue Nov 8, 2024 · 3 comments

Comments

@kered59
Copy link

kered59 commented Nov 8, 2024

Platform: Windows 10 / Electron
Issue: Keydown and Keyup Hook fails when a new getUserMediaStream of any device is initialized, however it only fails to do so when the electron client is focused. If the client is not focused while the Stream is allocated to a variable then the hook resumes correct functionality.

To replicate:

In main\index.ts add:

import {uIOhook} from 'uiohook-napi'
uIOhook.start();
uIOhook.on('keydown', (e) => {
console.log(e);
});

In any front end section such as Core add a call to navigator.mediaDevices.getUserMedia() utilizing navigator.mediaDevices.enumerateDevices() for grabbing your local Microphone DeviceId.

Once initialized, no logs are present.

@Istiniel
Copy link

same error, on the windows, mac. any advice, please? No error occured, no logs, very hard to debug

@mchammer1041
Copy link

You can find more details about your issue in this topic #42 . In fact, it has some some issue when your app uses WebRTC. I had this issue myselff as well and had to do a bad workaround: when the app is focused add listeners for keys using window.addEventListener and when app in not focused use uiohook-napi

@Istiniel
Copy link

You can find more details about your issue in this topic #42 . In fact, it has some some issue when your app uses WebRTC. I had this issue myselff as well and had to do a bad workaround: when the app is focused add listeners for keys using window.addEventListener and when app in not focused use uiohook-napi

thanks, that's a solution, but i have found another way to fix this bug. You have to create child process by using electron utilityProcess and initiate key listeners in that child process. If some conditions are met (for example shortcut is pressed or some key), and you want to emit message from main to renderer process, all you need is to postMessage from child process to main process and use webContents.send after

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants