SnosMe/uiohook-napi

Prevents other applications from listening for captured events

Yusuf007R opened this issue · 4 comments

Is there a way to achieve this?

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.

I see that makes sense thanks you :D

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

@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.

napi_value AddonStart(napi_env env, napi_callback_info info) {

Then check and prevent original non-copied event here.

void dispatch_proc(uiohook_event* const event) {
if (threadsafe_fn == NULL) return;
uiohook_event* copied_event = malloc(sizeof(uiohook_event));
memcpy(copied_event, event, sizeof(uiohook_event));
if (copied_event->type == EVENT_MOUSE_DRAGGED) {
copied_event->type = EVENT_MOUSE_MOVED;
}