SnosMe / uiohook-napi

MIT License
162 stars 37 forks source link

Prevents other applications from listening for captured events #21

Closed Yusuf007R closed 1 year ago

Yusuf007R commented 1 year ago

Is there a way to achieve this?

SnosMe commented 1 year ago

You can't prevent key presses because events are delivered asynchronously to js, at the point where your code runs it is too late to cancel them.

Yusuf007R commented 1 year ago

I see that makes sense thanks you :D

valueerrorx commented 1 year ago

so libuiokook should look out for some sort of "blockfile" where we could put some keycodes to block :-)

SnosMe commented 1 year ago

@valueerrorx If you know which keys to prevent in advance and don't need to check any conditions, then you can:

Pass array of keycodes from js side to C.

https://github.com/SnosMe/uiohook-napi/blob/63745a540828de230392eee3e6cf85d8a4d09e13/src/lib/addon.c#L180

Then check and prevent original non-copied event here.

https://github.com/SnosMe/uiohook-napi/blob/63745a540828de230392eee3e6cf85d8a4d09e13/src/lib/addon.c#L11-L18