Why PyAutoGui LocateOnScreen() only Returns None

前端 未结 11 1918
悲&欢浪女
悲&欢浪女 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条回答
  •  一生所求
    2020-12-15 11:37

    The locateOnScreen() function returns None if the image wasn't found on the screen. Remember, the match has to be pixel-perfect in order to match it, so be sure to crop index.png to the smallest recognizable size to prevent extra details from ruining your match. Also, make sure the thing you are looking for is not obscured by any other windows on top of it.

提交回复
热议问题