Salve sono un nuovo utente, cercando su internet ho trovato questo forum e dopo varie ricerche inutili ho deciso di chiedere aiuto qui.
Ho un problema con uno script che ho realizzato io, questo è il seguente errore preso dalla shell:
Traceback (most recent call last):
File "C:\Users\chris\Desktop\test\test.py", line 58, in <module>
x,y = pyautogui.locateCenterOnScreen('6.png', confidence=0.9)
TypeError: cannot unpack non-iterable NoneType object
il seguente errore avviene dopo vari cicli dello script e non prima, qualche idea?
codice python:
from pyautogui import *
import pyautogui
import time
import keyboard
import random
import win32api, win32con
time.sleep(3)
def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
while keyboard.is_pressed('q') == False:
time.sleep(0.5)
if pyautogui.locateOnScreen('1.png', confidence=0.9) != None:
x,y = pyautogui.locateCenterOnScreen('1.png', confidence=0.9)
click(x,y)
time.sleep(0.5)
else:
print("error 1")
time.sleep(0.5)
time.sleep(0.5)
if pyautogui.locateOnScreen('2.png', confidence=0.9) != None:
x,y = pyautogui.locateCenterOnScreen('2.png', confidence=0.9)
click(x,y)
time.sleep(0.5)
else:
print("error 2")
time.sleep(0.5)
time.sleep(0.5)
if pyautogui.locateOnScreen('3.png', confidence=0.9) != None:
x,y = pyautogui.locateCenterOnScreen('3.png', confidence=0.9)
click(x,y)
time.sleep(0.5)
else:
print("error 3")
time.sleep(0.5)
time.sleep(0.5)
if pyautogui.locateOnScreen('4.png', confidence=0.9) != None:
x,y = pyautogui.locateCenterOnScreen('4.png', confidence=0.9)
click(x,y)
time.sleep(0.5)
else:
print("error 4")
time.sleep(0.5)
time.sleep(0.5)
if pyautogui.locateOnScreen('5.png', confidence=0.9) != None:
x,y = pyautogui.locateCenterOnScreen('5.png', confidence=0.9)
click(x,y)
time.sleep(0.5)
else:
print("error 5")
time.sleep(0.5)
time.sleep(0.5)
if pyautogui.locateOnScreen('6.png', confidence=0.9) != None:
x,y = pyautogui.locateCenterOnScreen('6.png', confidence=0.9)
click(x,y)
time.sleep(0.5)
else:
print("error 6")
time.sleep(0.5)
time.sleep(0.5)
if pyautogui.locateOnScreen('7.png', confidence=0.9) != None:
x,y = pyautogui.locateCenterOnScreen('7.png', confidence=0.9)
click(x,y)
time.sleep(0.5)
else:
print("error 7")
time.sleep(0.5)
continue
grazie in anticipo
