-
Notifications
You must be signed in to change notification settings - Fork 123
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
Getting mouse position without listening to an event. #177
Comments
What OS is this happening on? I suspect it is Linux and that is a rather long conversation I don't want to type yet... You should try this on all 3 supported platforms, it will likely work on windows, macOS is a 50/50 but I suspect this works as well.
This is the ideal solution as the library should see it's own generated events.
Please explain this part further... I don't quite understand why/how this is an issue. I don't have an issues with multiple monitors but many others have expressed frustration.
This is possible on all platforms, I just don't know the exact API for windows and macOS. In X11, the API is XQueryPointer and there are examples on how to use it. |
I have wrote a function to get the x and y of the mouse for macos windows and x11 so that i could use it with libuiohook i could show the code here. Not sure how good it is but it seems to work fine when i tested it. |
Could you share it? |
Ignore all the other files, all you'll need is in the osx, win32, and x11 folders https://github.com/justdie386/luaohook/tree/main/src/mouse #ifdef _WIN32
#include <windows.h>
#include <winuser.h>
#include "win32/win32.h"
#define coords POINT
#elif __APPLE__
#include <unistd.h>
#include "osx/osx.h"
#define coords CGPoint
#else
#include <unistd.h>
#include "x11/x11.h"
#define coords MouseCoordinates
#endif |
Hey, @kwhat i didn't want to open another issue, but i forked libuiohook, added the code i showed earlier from https://github.com/justdie386/luaohook/tree/main/src/mouse to the input_helper.c/input_helper.h for all platforms, tested it, and it worked. I was wondering if you would want this getting the mouse coordinates without taking it from an event feature to be added, and how would you like it to work. I currently have it as get_mouse_coordinates(); it returns coordinates, and its coordinates.x and coordinates.y and thats it, but i'm not sure whetever it would fit the way the rest of the library works, what do you think. |
Hello. First, I would like to thank you for this library
Second, I'm trying to do some logic with moving mouse in my Qt app. Basically, I want to move the mouse and send clicks/releases based on my logic (I'm going to control another apps from my app).
Here are the cross platform ways I can think of with what blocks me:
1- Use Qt's QCursor.setPos which moves mouse and listen to mouse events using your library. I'm storing x and y of mouse move to track the mouse so when I send press/release event the library can use the tracked x and y to press at this location.
problem: QCursor.setPos does not trigger any mouse move event. This solution would have been ideal if this was not happening.
2- Same as 1 but instead QCursor.setPos, I will use your library to send mouse press/releases
problem: coordinates are not dpi aware, and has problems when multiple monitors are connected.
3- Find some way to get the mouse position without listening to event, and I will use that in the event when I press.
problem: I do not know how to do so.
What is the right solution for this based on your library? Thanks in advance
The text was updated successfully, but these errors were encountered: