Oct-07-2019, 09:10 PM
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)