问题描述
我有一个find.png"(附上)pyautogui.locateOnScreen 返回 None,即使在 20 个屏幕截图之后!!!!使用解释器(附代码)注意:1) 带有import pyautogui as auto"行的图像是find.png"2)我在同一个目录中有find.png",它被建立(用PIL-Image检查)
I have a "find.png" (attached)The pyautogui.locateOnScreen is returning None, even after 20 screenshots!!!!Using interpreter (code attached)Note: 1) the image having the line, "import pyautogui as auto", is "find.png"2)I have "find.png" in the same directory, it is founded( checked with PIL- Image)
推荐答案
在为此苦苦挣扎之后,终于想通了,您要么使用命令行,要么使用 windows 键打印屏幕按钮来截取屏幕截图.使用截图工具不起作用所以试试:
After struggling with this forever also, finally figured out that you either use command line or print screen button with the windows key to take the screenshot. Using the snipping tool does not workso try:
image = pyautogui.screenshot()
image.save('testing.png')
将 testing.png 裁剪得尽可能小,以便 locateOnScreen 工作得更快.然后返回终端并输入:
Go and crop testing.png as small as possible so that locateOnScreen works faster. Then go back to the terminal and type:
pyautogui.locateOnScreen('testing.png')
这篇关于Python 3.6.3 pyautogui.locateOnScreen 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!