I am trying to make a bot that will play an online game for me. To do this I need to take a screenshot and see if there is a specific colour in a specific location. The game requires this to be done as quickly as possible, and the code below is not fast enough as it can only complete roughly 7 times a second. Does anyone know of a better way to optimise this code to make it run faster?
import imageio
import pyautogui
run = True
while run:
myScreenshot = pyautogui.screenshot()
myScreenshot.save(r'location\answers.png')
pic = imageio.imread('answers.png')
red_pixel_col = pic[500, 163]
if red_pixel_col[0] == 208:
print('yes')
else:
print('no')
P.S You would need to replace location in the save line (line 6) with a valid path