![]() |
Pyautogui script runs fine if split into two parts together it does not - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Pyautogui script runs fine if split into two parts together it does not (/thread-21624.html) |
Pyautogui script runs fine if split into two parts together it does not - Bmart6969 - Oct-07-2019 Making a small bot to automate daily activities in a game the script runs fine and fully gets into the game. i Made another script to check resource levels that somewhat works other than needs tweaked for better accuracy. When i copy the resource reading script into the main bot script. it can no longer get into game. The mouse moves in the opposite direction of the redx even though it is verified through locate on screen to receive the coordinates of the button. No clue what's going on here. if collect != None: collect = pyautogui.locateOnScreen("collectshipment.png", confidence=0.9) (pyautogui.click(pyautogui.moveTo(collect, duration=1))) print("Collected Daily Reward") elif eventx != None: eventx = pyautogui.locateOnScreen("eventx.png", confidence=0.9) (pyautogui.click(pyautogui.moveTo(eventx, duration=1))) print("Closing Event Screen") elif redx != None: redx = pyautogui.locateOnScreen("redx.png", confidence=0.9) (pyautogui.click(pyautogui.moveTo(redx, duration=1))) print("Closed redx") else: print("Unknown Screen") ###this is where the two scripts were put together foodi = pyautogui.locateOnScreen("foodi.png", confidence=0.7) food1 = numpy.array(foodi) food1[0] += 32 food1[1] += 7 food1[2] += 30 food1[3] -= 10 food = pyautogui.screenshot(region=(food1[0], food1[1], food1[2], food1[3])) food.save(r'C:\Users\brady\PycharmProjects\Bot\foodc.png', grayscale=True) img = Image.open('foodc.png') print(pytesseract.image_to_string(img)) oili = pyautogui.locateOnScreen("oili.png", confidence=0.7) oil1 = numpy.array(oili) oil1[0] += 32 oil1[1] += 7 oil1[2] += 30 oil1[3] -= 10 oil = pyautogui.screenshot(region=(oil1[0], oil1[1], oil1[2], oil1[3])) oil.save(r'C:\Users\brady\PycharmProjects\Bot\oilc.png', grayscele=True) img1 = Image.open('oili.png') print(pytesseract.image_to_string(img1), "??") def get_text(image): return pytesseract.image_to_string(image) RE: Pyautogui script runs fine if split into two parts together it does not - Bmart6969 - Oct-07-2019 solved. gui is somehow defaulting to a generic location when finding none due to being scanning entire screen in the milisecond it took for the app to load next screen. it's leaving the gui in process of moving to a location while trying to locate the next statement. |