【发布时间】:2018-12-19 11:03:59
【问题描述】:
由于某些未知原因,Pyautogui 的 locateOnScreen() 函数(以及所有其他 Pyautogui 的定位函数)无法正常工作并返回 None。
我的代码:
>>> pyautogui.screenshot('test.png',region=(100,20, 30, 20))
<PIL.Image.Image image mode=RGB size=30x20 at 0x39E35C0>
>>> print pyautogui.locateOnScreen('test.png')
None
我的研究
我知道当它返回None 时,这意味着pyautogui 无法定位屏幕上的图像。我也知道它必须在屏幕上可见。上面的代码是在不移动单个窗口时执行的。
我也知道在 stackoverflow 中有非常相似/相同的问题,例如 this one。但是该问题的解决方案不适用于我的情况,因为我实际上是直接使用 pyautogui 的屏幕截图和裁剪功能,甚至没有使用 3rd 方软件进行裁剪,但 pyautogui 无法找到它。
其他信息
Python:2.7.15 (64-bit)
操作系统:Windows 10 Home 64-bit
【问题讨论】:
标签: python python-2.7 python-imaging-library pyautogui