Comments (10)
Hi, It is possible for Windows and OS X systems, however, it is not currently possible on Linux or Unix. To use this functionality, you need to set the reserved flag of the uiohook_event structure to 0x1
when you recieve the event on callback. This flag must be set synchronously on the same thread as the callback is received on. So far, only the mask 1 >> 0
is supported for the reserved field.
from libuiohook.
Please look at this file https://github.com/WilixLead/iohook/blob/master/src/iohook.cc
For tests I just make this:
case EVENT_KEY_PRESSED:
case EVENT_KEY_RELEASED:
case EVENT_KEY_TYPED:
case EVENT_MOUSE_PRESSED:
case EVENT_MOUSE_RELEASED:
case EVENT_MOUSE_CLICKED:
case EVENT_MOUSE_MOVED:
case EVENT_MOUSE_DRAGGED:
case EVENT_MOUSE_WHEEL:
event->reserved = 0x1; // <----- THIS
uiohook_event event_copy;
memcpy(&event_copy, event, sizeof(uiohook_event));
As I think, It should prevent all propagation. But really no :(
Where Im wrong?
from libuiohook.
Thank you!
But. I use parts of code from examples and my code looks like this:
void dispatch_proc(uiohook_event * const event) {
switch (event->type) {
....
case EVENT_KEY_PRESSED:
case EVENT_KEY_RELEASED:
case EVENT_KEY_TYPED:
case EVENT_MOUSE_PRESSED:
case EVENT_MOUSE_RELEASED:
case EVENT_MOUSE_CLICKED:
case EVENT_MOUSE_MOVED:
case EVENT_MOUSE_DRAGGED:
case EVENT_MOUSE_WHEEL:
event->reserved = 0x1;
......
break;
}
}
But events still emits to the system. What I'm doing wrong?
from libuiohook.
That looks correct, which branch are you compiling? The master branch is probably broken and 1.1 is the current stable.
from libuiohook.
I use 1.1 branch. Some later I try remove current version of libuiohook and clone clean 1.1. But I think it is not help.
What should happen if I prevent key? When I type something and always set reserverd = 0x1, nothing will be typed (in notepad or terminal for example) ?
from libuiohook.
Yes, if you set the reserved flag, it will prevent the event it was set for from propagating. So if it was a mouse move event, the mouse will not move. If it was a key down and key up, you will not be able to type.
from libuiohook.
Please post the code you are using for the callback so I may better help you.
from libuiohook.
I am not sure if it matters in your implementation, but the reserved flag must be set on the same thread context that it was called from. So you cannot copy the memory to a different thread.
from libuiohook.
Is it still the case that preventing event propagation is not possible on *nix?
If so are there any plans to add this functionality?
Thanks
from libuiohook.
It's not possible on X11 due to some technical limitations and I doubt that will ever change. It maybe possible on Wayland, but that hasn't really seen widespread adoption thus far. Migrating this library to wayland is going to take substantial effort and I haven't really looked into it much at this point. If anyone really wants this functionality, start looking into wayland to see this maybe possible. I only have so many hours in a day and right now 2.2 getting finalized and a 3.0 refactor to fix several other long standing issues are a priority.
from libuiohook.
Related Issues (20)
- Can't type special characters with right alt HOT 3
- replace key ouput with other value HOT 11
- Caps lock can't be suppressed on Mac OS Monterey HOT 1
- Posting Keys Does Not Work in Games on Windows
- KeyTyped event wasn't emitted for @ on German keyboard layout HOT 10
- hook_create_screen_info doesn't work correctly on Windows when there are multiple screens HOT 1
- Darwin Segfualt on CGEventTapCreate failure
- [Feature Request] Add support for Mac Catalyst HOT 7
- Address issues with Windows hook restarts HOT 2
- coordinates multiplied by two for the mouse on windows HOT 9
- error in the readme HOT 1
- Add keychar support to press and release HOT 2
- Remap a keyboard key as a left mouse button unable to register a double click HOT 1
- Getting mouse position without listening to an event. HOT 4
- add libuiohook as a package on xmake-repo HOT 2
- `keycode` does not match (all?) definitions from `uiohook.h` on Windows HOT 6
- Help for Compiling on Windows HOT 3
- The KEYEVENTF_EXTENDEDKEY flag is not added to every key that needs it when simulating keyboard events on Windows HOT 3
- Deadlock when used with NodeJS NAPI module
- Remove USE_XRECORD_ASYNC build flag.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libuiohook.