- Looks for an image
- If it finds
ait tries to find a match for any image in the array
- If it finds an image in
image_listit looks for
- If it finds
eit logs it and moves the mouse to
x, ychecks for pixel colour and then clicks when when it finds a match, clicks.
This is where my problem arises my
avoidLog() function is being called 2-3 times per click. I’ve added
print("click") to check if it’s actually clicking and it isn’t, it’s clicking at the right time but for some reason, my log is triggering more than once.
It’s logging correctly, just an odd number of times.
I know python is operating in a single thread in my example so I’m not sure why it’s looping back round and not clicking. It would make more sense to me if it was clicking multiple times and logging multiple times.
import pyautogui as py def avoidLog(): avoidLog = open('Avoided.txt', 'a') avoidLog.write("Found at: " + str(f) + " at: " + str(skipTime)) avoidLog.write("n") avoidLog.close() image_list =  while True: if py.locateOnScreen('a.jpg') != None: for image in image_list: found = py.locateCenterOnScreen(image) if found != None: skipTrigger = py.locateOnScreen('e.jpg') if skipTrigger != None: avoidLog() py.moveTo(x, y) r = py.pixelMatchesColor(x,y, (r,g,b)) if r == True: py.sleep(2) print("click") py.click() break
avoidLog() is called whenever e.jpg is located. However, py.click() is only called if pixelMatchesColor is True