python 3.9.7 pyautogui 0.9.53
Having it look for images then moveRel and click but it's doesn't find the image it returns non-iterable
I have done to make sure it's finding the image
while 1:
time.sleep(1)
if pyautogui.locateOnScreen('ScheduledBy.png', confidence=0.8) is not None:
print("Found")
else:
print("Nope")
I'm able to find them just fine without false results
import pyautogui
import time
import keyboard
import random
import win32api, win32con
def FindContact1():
pyautogui.click(319,25)
pyautogui.click(99,161)
if pyautogui.locateOnScreen('ScheduledBy.png', confidence=0.8) is not None:
pyautogui.moveTo('ScheduledBy.png')
pyautogui.moveRel(245,20)
time.sleep(.1)
pyautogui.click()
time.sleep(.75)
if pyautogui.locateOnScreen('Email.png', confidence=0.8) is not None:
pyautogui.moveTo('Email.png')
pyautogui.moveRel(0,20)
time.sleep(.2)
pyautogui.tripleClick()
time.sleep(.1)
pyautogui.hotkey('ctrl', 'c')
time.sleep(.1)
pyautogui.click(88,25)
time.sleep(.5)
if pyautogui.locateOnScreen('Cced.png', confidence=0.8) is not None:
pyautogui.moveTo('Cced.png')
pyautogui.moveRel(-44,0)
time.sleep(.1)
pyautogui.click()
pyautogui.hotkey('ctrl', 'v')
Log:
File "C:\Users\CDoz\OneDrive\Documents\Projects\Python\One Exhibit Request\One Exhibit Request\FindSheduledBy.py", line 175, in Contacts
FindContact1()
File "C:\Users\CDoz\OneDrive\Documents\Projects\Python\One Exhibit Request\One Exhibit Request\FindSheduledBy.py", line 135, in FindContact1
pyautogui.moveTo('Cced.png')
File "C:\Users\CDoz\AppData\Roaming\Python\Python39\site-packages\pyautogui\__init__.py", line 598, in wrapper
returnVal = wrappedFunction(*args, **kwargs)
File "C:\Users\CDoz\AppData\Roaming\Python\Python39\site-packages\pyautogui\__init__.py", line 1280, in moveTo
x, y = _normalizeXYArgs(x, y)
TypeError: cannot unpack non-iterable NoneType object
>>>
I tried this solution based on other posts that looked for images, but either I didn't do it right or it didn't work
Post :Python pyautogui bot works for some time and then TypeError: cannot unpack non-iterable NoneType object Solution Post: PyAutoGui TypeError: cannot unpack non-iterable NoneType object
def FindContact1():
ScheduledBy = pyautogui.locateOnScreen('ScheduledBy.png', confidence=0.8)
Email = pyautogui.locateOnScreen('Email.png', confidence=0.8)
Cced = pyautogui.locateOnScreen('Cced.png', confidence=0.8)
pyautogui.click(319,25)
pyautogui.click(99,161)
if ScheduledBy is not None:
pyautogui.moveTo('ScheduledBy.png')
pyautogui.moveRel(245,20)
time.sleep(.1)
pyautogui.click()
time.sleep(.75)
if Email is not None:
pyautogui.moveTo('Email.png')
pyautogui.moveRel(0,20)
time.sleep(.2)
pyautogui.tripleClick()
time.sleep(.1)
pyautogui.hotkey('ctrl', 'c')
time.sleep(.1)
pyautogui.click(88,25)
time.sleep(.5)
if Cced is not None:
pyautogui.moveTo('Cced.png')
pyautogui.moveRel(-44,0)
time.sleep(.1)
pyautogui.click()
pyautogui.hotkey('ctrl', 'v')
I can make any small changes to it and it will start working again and stop working after a day.
def FindContact1():
ScheduledBy = pyautogui.locateOnScreen('ScheduledBy.png', confidence=0.8)
Email = pyautogui.locateOnScreen('Email.png', confidence=0.8)
Cced = pyautogui.locateOnScreen('Cced.png', confidence=0.8)
pyautogui.click(319,25)
pyautogui.click(99,161)
time.sleep(1)
if ScheduledBy is not None:
print('Found Scheduled')
pyautogui.moveTo('ScheduledBy.png')
pyautogui.moveRel(245,20)
time.sleep(.1)
pyautogui.click()
time.sleep(2)
if pyautogui.locateOnScreen('Email.png', confidence=0.8) is not None:
print("Found Email")
pyautogui.moveTo('Email.png')
pyautogui.moveRel(0,20)
time.sleep(.2)
pyautogui.tripleClick()
time.sleep(.1)
pyautogui.hotkey('ctrl', 'c')
time.sleep(.1)
pyautogui.click(88,25)
time.sleep(2)
if pyautogui.locateOnScreen('Cced.png', confidence=0.8) is not None:
print("Found CCed")
pyautogui.moveTo('Cced.png')
pyautogui.moveRel(-44,0)
time.sleep(.1)
pyautogui.click()
pyautogui.hotkey('ctrl', 'v')