Closed DMI-1407 closed 1 year ago
Yo!
returns absolute mouse positioning instead of relative positioning to my application?
There is no native way to do this as far as Im concerned, the mouse position on windows is always relative to your primary monitors top left corner.
However, to get the relative mouse position to your window, you just have to do some basic math with the position of your window?
Use a library such as pygetwindow
to grab your window and get it's boundaries on the monitor, then your relative coordinates are simply mouse_x - window_x, mouse_y - window_y
EDIT: I might have misread the question, it does return the absolute mouse position.
Hi,
maybe im blind or so.
I don't see how to tell the driver to return absolute mouse positions (i speak from these 2 byte values you get for X and Y Axis), whatever i do i get relative positions (so - or + up to 14 of the current position).
I know i can set the mouse to an absolute position using MouseFlag.MOUSE_MOVE_ABSOLUTE
but that's not my interest.
Could you provide an working out of the box example that prints the X position (absolute) when the mouse is moved ?
(also i think your md examples don't work, since capture_mouse
is not in Interception
)
Literally just
import interception
while 1:
print(interception.mouse_position())
Will print the absolute mouse position of the cursor on your screen.
Also beware that they are not byte values.
ok this works... but its using win32api and not the interception driver. :/
@DMI-1407 Indeed because the driver doesnt provide any way to get the mouse position, the driver deals with the mouse / keyboard device-stream only, it doesn't care where the mouse pointer currently is.
And iirc, win32api is a dependency of pyinterception anyways because its required to translate the keycodes for your keyboard layout properly.
Im a little bit confused by how to configure the interception driver so that it returns absolute mouse positioning instead of relative positioning to my application? I always ended up using a second library to read the mouse position, can you guys provide an example or did i misunderstood that completely and the absolute positioning is only for writing? (I had this problem already with the old library)