You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if someone would be able to help me with a problem I am facing.
The code below is meant to intercept the mouse input and translate it by a factor of 2.
However, it stops working after intercepting the first two on_move mouse events and locks up the mouse.
I suspect it is something to do with concurrency and the listener but am unsure.
Any help would be appreciated 😄
I have tested your application, and it does indeed crash for me with the message short format requires (-0x7fff - 1) <= number <= 0x7fff when running under XWayland. This is caused by by the values passed to self.mouse.move: Xlib requires short integers, that is signed 16 bit values.
Now, whether this should be handled by pynput is a difficult question---one solution would be to wrap the error in a generic ValueError and mark the method as raising that particular exception, another would be to cap the input values.
The root cause, however, is in your algorithm. pynput.mouse.Listener.on_move will be called when you call self.mouse.move, thus triggering another call to move the pointer, eventually leading to an overflow. You will need to react only to user triggered move callbacks.
Hi,
I was wondering if someone would be able to help me with a problem I am facing.
The code below is meant to intercept the mouse input and translate it by a factor of 2.
However, it stops working after intercepting the first two on_move mouse events and locks up the mouse.
I suspect it is something to do with concurrency and the listener but am unsure.
Any help would be appreciated 😄
The text was updated successfully, but these errors were encountered: