Why PyAutoGui LocateOnScreen() only Returns None

前端 未结 11 1932
悲&欢浪女
悲&欢浪女 2020-12-15 10:39

Here\'s the code that I\'m trying to run:

import pyautogui
r=pyautogui.locateOnScreen(\'C:\\Users\\David\\Desktop\\index.png\',grayscale=False)
print r
         


        
11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-15 11:22

    I was encountering the same problem, what I did is

    import pyautogui 
    r= None 
    while r is None:
        r=pyautogui.locateOnScreen('C:\Users\David\Desktop\index.png',grayscale=False)
    print r
    

    I think its just because that it takes time to locate image. If you found a better solution share with me :)

提交回复
热议问题