So I was reading the automate the boring stuff book, and on chapter 20 it talks about the pyautogui module and some of its functions.
The first one I had a problem with was the .mouseInfo function, which is supposed to open a window that gives you the color of the pixel your cursor is in.
When I try to use it, I get this error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Rafael\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 1895, in __call__
return self.func(*args)
File "C:\Users\Rafael\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 816, in callit
func(*args)
File "C:\Users\Rafael\AppData\Roaming\Python\Python38\site-packages\mouseinfo\__init__.py", line 339, in _updateMouseInfoTextFields
self.colorFrame.configure(background=hexColor)
File "C:\Users\Rafael\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 1649, in configure
return self._configure('configure', cnf, kw)
File "C:\Users\Rafael\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 1639, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: invalid color name "#FFFFX1"
Then, the window opens, and the RGB Color is 255, 255, -1, and the Hex color is #FFFFX1, neither of which are valid. If I try to use the function anywhere else on the screen these values stay the same. Also, if I try to move the mouse I still get the same colors.
The second problem I had was with the .pixel function, which is supposed to return the color at the pixel your mouse is at. My problem with this function is that sometimes it works, but sometimes I get this error:
Traceback (most recent call last):
File "<pyshell#93>", line 1, in <module>
pyautogui.pixel(0, 0)
File "C:\Users\Rafael\AppData\Roaming\Python\Python38\site-packages\pyscreeze\__init__.py", line 584, in pixel
return (r, g, b)
File "C:\Users\Rafael\AppData\Local\Programs\Python\Python38\lib\contextlib.py", line 120, in __exit__
next(self.gen)
File "C:\Users\Rafael\AppData\Roaming\Python\Python38\site-packages\pyscreeze\__init__.py", line 113, in __win32_openDC
raise WindowsError("windll.user32.ReleaseDC failed : return 0")
OSError: windll.user32.ReleaseDC failed : return 0
Even though I don't change anything, I get this error.
Would really appreciate some help.