原本是想用AutoPyGUI写一个健康打卡脚本的,遇到如下错误。
源程序:
import pyautogui
pyautogui.click(x=1850, y=285) #移动鼠标,然后点击
pyautogui.click(clicks=2, interval=0.25) #双击,间隔秒数
import pyscreeze
# im1 = pyscreeze.screenshot()
# im2 = pyscreeze.screenshot('my_screenshot.png')
# for i in pyautogui.locateAllOnScreen('HKU.png'):
# list(pyautogui.locateAllOnScreen('HKU.png'))
# pyautogui.locateOnScreen('looksLikeThis.png')
pyautogui.screenshot('HKU.png') # returns a Pillow/PIL Image object, and saves it to a file
# <PIL.Image.Image image mode=RGB size=1920x1080 at 0x31AA198>
buttonlocation = pyautogui.locateOnScreen('D:\VScode\HKU.png')
# buttonlocation = pyautogui.locateOnScreen('D:\VScode\微服务.png')
# buttonlocation = pyautogui.locateOnScreen('D:\VScode\服务平台.png')
# buttonlocation = pyautogui.locateOnScreen('D:\VScode\健康打卡.png')
# pyautogui.scroll(-10) # scroll down 10 "clicks"
# buttonlocation = pyautogui.locateOnScreen('D:\VScode\更改.png')
# # pyautogui.scroll(-10) # scroll down 10 "clicks"
# buttonlocation = pyautogui.locateOnScreen('D:\VScode\确认.png')
# # pyautogui.scroll(-10) # scroll down 10 "clicks"
# # pyautogui.write('36.3', interval=0.25) # prints out "Hello world!" with a quarter second delay after each character
# buttonlocation = pyautogui.locateOnScreen('D:\VScode\提交.png')
# buttonlocation = pyautogui.locateOnScreen('D:\VScode\确认2.png')
# buttonlocation = pyautogui.locateOnScreen('D:\VScode\确认2.png')
buttonpoint = pyautogui.center(buttonlocation)
buttonx, buttony = buttonpoint
pyautogui.click(buttonx, buttony)
提示错误:
```python
Traceback (most recent call last):
File "d:\VScode\AutoHKU.py", line 34, in <module>
buttonpoint = pyautogui.center(buttonlocation)
File "C:\Users\(用户名)\AppData\Local\Programs\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 582, in center
return Point(coords[0] + int(coords[2] / 2), coords[1] + int(coords[3] / 2))
TypeError: 'NoneType' object is not subscriptable
类型错误:“空类型”目标不是下标,但代码行没有下标啊。