Open domluther opened 5 years ago
I Have the same problem, except mine is parameter 2
here is my error message:
Traceback (most recent call last):
File "C:\Users\anon\Dropbox\Python programs\scratch game bot.py", line 33, in
Windows 10
Is there any fix for this?
even i have the same problem...
Traceback (most recent call last):
File "c:\Users\CSC\Desktop\my code\python\dino.py", line 44, in
the same to me, i got the same error text ` p = tuple(ag.pixel(x, y))
File "C:\Users\P7XXTM1-G\AppData\Roaming\Python\Python37\site-packages\pyscreeze__init__.py", line 578, in pixel color = windll.gdi32.GetPixel(hdc, x, y)
ctypes.ArgumentError: argument 2: <class 'TypeError'>: Don't know how to convert parameter 2`
Ran into this issue myself. It seems that this is only an issue if you have the opencv-python module installed.
same for me, px = pyautogui.pixel(x, y) gives this error: color = windll.gdi32.GetPixel(hdc, x, y) ctypes.ArgumentError: argument 2: <class 'TypeError'>: Don't know how to convert parameter 2
I also have opencv-python installed.
The TypeError might be to receiving a NULL value or None.
I think this might be related to change in default behaviour.
int(None)
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
See my writeup here from another issue i found and created a PR for: https://github.com/asweigart/pyautogui/issues/690#issue-1205346679
I was also having this error:
color = windll.gdi32.GetPixel(hdc, x, y)
ctypes.ArgumentError: argument 2: <class 'TypeError'>: Don't know how to convert parameter 2
Casting the parameters to int as follows solved my problem:
px = pyautogui.pixel(int(x), int(y))
I use coords = pyautogui.locateCenterOnScreen() and it returns a list of the co-ordinates in int64 format.
I then use pyautogui.pixel(coords) on that to try to work out what colour that pixel is and hit an error because pixel() on Windows seems to only handle int and not int64. The relevant error message is..
Am I using this wrong? The only way I can get around this is to manually cast the returned coords to regular int and then it works perfectly.