Python Forum
Pyautogui script runs fine if split into two parts together it does not
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pyautogui script runs fine if split into two parts together it does not
#1
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)
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to do 100 runs simulation based on the current codes? dududada 6 900 Sep-03-2023, 01:43 PM
Last Post: deanhystad
  Pyautogui, İmagesearch, Moving target Beyazx 0 549 Jun-27-2023, 08:47 PM
Last Post: Beyazx
  Another program runs bho68 7 1,143 Nov-08-2022, 08:16 PM
Last Post: bho68
  PyautoGUI- How to use If - Else with pyautogui.locateCenterOnScreen Tiel 3 8,123 Jun-27-2022, 02:00 PM
Last Post: DeaD_EyE
  pyautogui.locateOnScreen producing error dude8074 6 3,730 Apr-17-2022, 05:05 PM
Last Post: bowlofred
  How to fine tune cutecharts? Gigux 1 1,205 Jan-28-2022, 05:41 PM
Last Post: Larz60+
  For Loop Works Fine But Append For Pandas Doesn't Work knight2000 2 1,929 Dec-18-2021, 02:38 AM
Last Post: knight2000
  Importing a function from another file runs the old lines also dedesssse 6 2,478 Jul-06-2021, 07:04 PM
Last Post: deanhystad
  [split] Help- converting file with pyton script eltomassito 6 3,190 Jul-02-2021, 05:29 PM
Last Post: snippsat
  how to take a screnshot by Pyautogui automatically and randomly rachidel07 0 3,482 Feb-03-2021, 01:16 PM
Last Post: rachidel07

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020