0

Why code in python 3 wont work always?

For example i have "code" that i wrote about year ago. Its bad but its might work. import pyautogui SCREEN = pyautogui.size() POWER = 5 STEP = 32 sideX,sideY = SCREEN sideX-=32 sideY-=32 zone = [] WORG=[sideX/POWER,sideY/POWER] RGB=[0,0,0] pyautogui.FAILSAFE = False for partX in range(POWER): for partY in range(POWER): zone.append((WORG[0]*partX,WORG[1]*partY)) for Nom in zone: X = Nom[0] Y = Nom[1] partX = WORG[0]+X partY = WORG[1]+Y while Y < partY: while X < partX: if pyautogui.pixelMatchesColor((int(X)) ,(int(Y)), RGB ,10): print(X,Y) pyautogui.moveTo(int(X),int(Y)) X+=STEP X=Nom[0] Y+=STEP I try today launch it but its only work in 3 time. I use Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32. So i want to know "Why THIS code in python 3 wont work always?"

27th Aug 2021, 3:23 PM
Hameleon
Hameleon - avatar
2 Réponses
+ 2
What do you mean by "didn't work"? Was it a logical error or a code error?
27th Aug 2021, 9:13 PM
Chloe
Chloe - avatar
0
0.0 233.6 281.6 64.0 Traceback (most recent call last): File "C:\Users\New Member\workjob\Pl.py", line 22, in <module> if pyautogui.pixelMatchesColor((int(X)) ,(int(Y)), RGB ,10): File "C:\Users\New Member\AppData\Local\Programs\Python\Python38\lib\site-packages\pyscreeze\__init__.py", line 607, in pixelMatchesColor pix = pixel(x, y) File "C:\Users\New Member\AppData\Local\Programs\Python\Python38\lib\site-packages\pyscreeze\__init__.py", line 597, in pixel return (r, g, b) File "C:\Users\New Member\AppData\Local\Programs\Python\Python38\lib\contextlib.py", line 120, in __exit__ next(self.gen) File "C:\Users\New Member\AppData\Local\Programs\Python\Python38\lib\site-packages\pyscreeze\__init__.py", line 122, in __win32_openDC raise WindowsError("windll.user32.ReleaseDC failed : return 0") OSError: windll.user32.ReleaseDC failed : return 0
28th Aug 2021, 9:30 AM
Hameleon
Hameleon - avatar