SavinaRoja / PyUserInput

A module for cross-platform control of the mouse and keyboard in python that is simple to install and use.
GNU General Public License v3.0
1.07k stars 244 forks source link

Fix long int overflow on Windows #97

Closed CostantiniMatteo closed 7 years ago

CostantiniMatteo commented 7 years ago

Hi,

I have two screens connected to my computer and when the mouse is inside the second screen and I run:

m = PyMouse()
m.click(*m.position())

I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python36\lib\site-packages\pymouse\base.py", line 56, in click
    self.press(x, y, button)
  File "C:\Program Files\Python36\lib\site-packages\pymouse\windows.py", line 34, in press
    win32api.mouse_event(buttonAction, x, y)
OverflowError: Python int too large to convert to C long

The cause are the coordinates returned by m.position() that are unsigned long while click() expects singed long values.

I fixed this by making position() return a signed long tuple.

EDIT: I just noticed I forked the wrong repository. I'm opening the same pull request in the correct one.

pepijndevos commented 7 years ago

Merged in the other repo