I’m trying to get pyautogui to check for one image, then another, then imagenotfoundexception, but I don’t know if this is possible.
<code>from pyautogui import *
import pyautogui
import time
import keyboard
import random
import win32api, win32con
while 1:
try:
pyautogui.locateOnScreen('Dassault Falcon 7X.png',confidence=0.4)
print ("I can see a Dassault Falcon!")
time.sleep(0.5)
except pyautogui.locateOnScreen('blimp.png',confidence=0.4):
print ("I can see a balloon!")
time.sleep(0.5)
except ImageNotFoundException:
print ("Nope nothing there")
</code>
<code>from pyautogui import *
import pyautogui
import time
import keyboard
import random
import win32api, win32con
while 1:
try:
pyautogui.locateOnScreen('Dassault Falcon 7X.png',confidence=0.4)
print ("I can see a Dassault Falcon!")
time.sleep(0.5)
except pyautogui.locateOnScreen('blimp.png',confidence=0.4):
print ("I can see a balloon!")
time.sleep(0.5)
except ImageNotFoundException:
print ("Nope nothing there")
</code>
from pyautogui import *
import pyautogui
import time
import keyboard
import random
import win32api, win32con
while 1:
try:
pyautogui.locateOnScreen('Dassault Falcon 7X.png',confidence=0.4)
print ("I can see a Dassault Falcon!")
time.sleep(0.5)
except pyautogui.locateOnScreen('blimp.png',confidence=0.4):
print ("I can see a balloon!")
time.sleep(0.5)
except ImageNotFoundException:
print ("Nope nothing there")
I tried to make imagenotfoundexception into finally but it wouldn’t work and no matter what I did I got the imagenotfoundexception error.
New contributor
mmewtwosaysbye is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.