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

Example breaks on Python 3.6.9 #118

Closed marto1 closed 4 years ago

marto1 commented 4 years ago

Hi,

In the first example:

from pymouse import PyMouse
from pykeyboard import PyKeyboard

m = PyMouse()
k = PyKeyboard()

x_dim, y_dim = m.screen_size()
m.click(x_dim/2, y_dim/2, 1)
k.type_string('Hello, World!')

I get a traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/myvenv/lib/python3.6/site-packages/pymouse/base.py", line 56, in click
    self.press(x, y, button)
  File "/home/user/myvenv/lib/python3.6/site-packages/pymouse/x11.py", line 90, in press
    self.move(x, y)
  File "/home/user/myvenv/lib/python3.6/site-packages/pymouse/x11.py", line 128, in move
    fake_input(d, X.MotionNotify, x=x, y=y)
  File "/home/user/myvenv/lib/python3.6/site-packages/Xlib/ext/xtest.py", line 103, in fake_input
    y = y)
  File "/home/user/myvenv/lib/python3.6/site-packages/Xlib/protocol/rq.py", line 1347, in __init__
    self._binary = self._request.to_binary(*args, **keys)
  File "/home/user/myvenv/lib/python3.6/site-packages/Xlib/protocol/rq.py", line 1069, in to_binary
    static_part = struct.pack(self.static_codes, *pack_items)
struct.error: required argument is not an integer

Forcing the arguments to be integers solves this problem:

m.click(int(x_dim/2), int(y_dim/2), 1)

Note: screen size is 1366x768

marto1 commented 4 years ago

just saw the notice sorry