PyUserInput icon indicating copy to clipboard operation
PyUserInput copied to clipboard

Function `click` does not transform argument to `int` automatically

Open PaleNeutron opened this issue 9 years ago • 3 comments

I tried the code in readme but got error like this:

>>> x_dim, y_dim = m.screen_size()
>>> m.click(x_dim/2, y_dim/2, 1)
Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    m.click(x_dim/2, y_dim/2, 1)
  File "C:\Python34\lib\site-packages\pymouse\base.py", line 56, in click
    self.press(x, y, button)
  File "C:\Python34\lib\site-packages\pymouse\windows.py", line 32, in press
    self.move(x, y)
  File "C:\Python34\lib\site-packages\pymouse\windows.py", line 70, in move
    windll.user32.SetCursorPos(x, y)
ctypes.ArgumentError: argument 1: <class 'TypeError'>: Don't know how to convert parameter 1

This is because x_dim/2 is 960.0 not 960.

So, add a type coercions or modify the readme.

PaleNeutron avatar Feb 22 '15 23:02 PaleNeutron

Facing same error in ubuntu - Traceback (most recent call last): File "Joystic.py", line 34, in myMouse.click(x_cur, y_cur, click) File "build/bdist.linux-x86_64/egg/pymouse/base.py", line 45, in click File "build/bdist.linux-x86_64/egg/pymouse/unix.py", line 34, in press File "/usr/lib/python2.7/dist-packages/Xlib/ext/xtest.py", line 100, in fake_input y = y) File "/usr/lib/python2.7/dist-packages/Xlib/protocol/rq.py", line 1456, in init self._binary = self._request.to_binary(_args, *_keys) File "", line 2, in to_binary struct.error: cannot convert argument to integer

ajitjadhav28 avatar Jun 21 '16 08:06 ajitjadhav28

I'd insta-merge a PR on https://github.com/PyUserInput/PyUserInput for such a type coercion, but I have an exam today, so I don't have the time to write and test a patch.

pepijndevos avatar Jun 21 '16 08:06 pepijndevos

It's Ok.. Thanks for developing such a nice utility. All the best for your exam..

ajitjadhav28 avatar Jun 21 '16 11:06 ajitjadhav28