Multithreaded pyautogui validations stop working after 40~60 minutes

我的梦境 提交于 2019-12-13 03:45:45

问题


AI Sweigart, I am having problems with your pyautogui.

I made a bot for a game that uses your lib: multithreaded infinite loops based on checked actions that activate it, validating screen matches and images, and it works perfectly for 40~50 minutes.

But, suddenly, it stops working, and today I found out that it happens on the locateOnScreen and/or PixelMatchesColor validations.

The error is 'screen grab failed', and this keep happening until I finish the application and run it again.

How can it be possible to work for almomst 1 hour, and the crash? Is it a bug?

I am trying to fix this by importing pyautogui again on except, but I don't know yet if this will work.

But the point is that I have no idea about what is going on and what should I do.

Hope you can help me!

Your's,

Zed.

while True: try:

    if not pyautogui.pixelMatchesColor(int(int(equip) + int(x)), int(y_mp), validate_colors(heavy_mp_color)):
        if pyautogui.locateOnScreen(resource_path('images\\aaaaa.png'), grayscale=True, confidence=0.8):
            if pyautogui.locateOnScreen(resource_path('images\\bbbb.png'), grayscale=True, confidence=0.8):
                if len(entry_equip) == 1:
                    pyautogui.hotkey(entry_equip[0].lower())
                else:
                    pyautogui.hotkey(entry_equip[0].lower(), entry_equip[1].lower())
    elif pyautogui.pixelMatchesColor(int(int(unequip) + int(x)), int(y_mp), validate_colors(heavy_mp_color)):
        if len(entry_unequip) == 1:
            pyautogui.hotkey(entry_unequip[0].lower())
        else:
            pyautogui.hotkey(entry_unequip[0].lower(), entry_unequip[1].lower())
    sleep(1)
except Exception as ex:
    print('def x ' + str(ex))
    continue







except Exception as ex:
    print('def x ' + str(ex))
    import pyautogui
    continue

来源:https://stackoverflow.com/questions/56465751/multithreaded-pyautogui-validations-stop-working-after-4060-minutes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!