Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pyautogui while loop
#1
Having an issue with my script i am trying to get the script to wait until an image is no longer displayed on screen to continue to the next task. Here is what i have hangs up and just keeps posting Please wait.

invalid = pyautogui.locateOnScreen("loadingscreen.png", confidence=0.7)

time.sleep(8)
loading = pyautogui.locateOnScreen("loadingscreen.png", confidence=0.7)
print(loading)
while loading != invalid:
    time.sleep(2)
    print("Please wait")
    if loading == invalid:
        print("Success")
Was hoping to pull values from the loading screen while it was visible to when it was not to end loop. Does anyone know a way to do this? Sorry for my ignorance this is only the 2nd day of python for me.

invalid = pyautogui.locateOnScreen("zdayloadingscreen.png", confidence=0.7)

time.sleep(8)
loading = pyautogui.locateOnScreen("zdayloadingscreen.png", confidence=0.7)
print(loading)
while loading != invalid:
    time.sleep(2)
    loading = pyautogui.locateOnScreen("zdayloadingscreen.png", confidence=0.7)#Must update value within loop
    print("Please wait")
    if loading == invalid:
        print("Success")
Figured it out!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pyautogui, İmagesearch, Moving target Beyazx 0 591 Jun-27-2023, 08:47 PM
Last Post: Beyazx
  PyautoGUI- How to use If - Else with pyautogui.locateCenterOnScreen Tiel 3 8,385 Jun-27-2022, 02:00 PM
Last Post: DeaD_EyE
  pyautogui.locateOnScreen producing error dude8074 6 3,850 Apr-17-2022, 05:05 PM
Last Post: bowlofred
  how to take a screnshot by Pyautogui automatically and randomly rachidel07 0 3,554 Feb-03-2021, 01:16 PM
Last Post: rachidel07
Sad problem with Pyautogui rachidel07 1 2,473 Jan-27-2021, 05:43 PM
Last Post: nilamo
  pyautogui with a display emulator? gumby4231 0 2,606 Jul-30-2020, 02:46 PM
Last Post: gumby4231
  pyautogui.screenshot region is not working alexlu 6 6,519 Jun-04-2020, 10:46 AM
Last Post: alexlu
  loop in pyautogui (python automation GUI application) pyprogrammer 0 4,804 Feb-12-2020, 02:52 PM
Last Post: pyprogrammer
  Doesn't work function pyautogui.typewrite() aliyevmiras 1 4,814 Dec-22-2019, 11:35 AM
Last Post: aliyevmiras
  Can't run pyautogui on Mohave veromi22 4 2,952 Sep-30-2019, 12:41 AM
Last Post: veromi22

Forum Jump:

User Panel Messages

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