这是一段自动识别钉钉直播并自动点击直播的代码,期望效果是等到直播通知(dingtalk live.png)出现后点击并进入
为什么我这行代码的8-11行不能定位图片位置而是直接点击鼠标当前位置
import tkinter as tk
import pyautogui as pya
import time
def click():
aim = pya.locateOnScreen('dingtalk live.png')
while True:
if pya.locateOnScreen('dingtalk live.png'):
pya.click(aim)
break
else:
print("下一次循环")
time.sleep(3)
window = tk.Tk()
window.title('自动打开钉钉直播')
window.geometry('500x500')
head = tk.Label(window, text='自动打开', bg='pink', font=('微软雅黑', 14), width=36, height=3)
head.pack()
writer = tk.Label(window, text='coded by 陈欣然', bg='white', font=('微软雅黑',6), width=12,height=4)
writer.pack()
start = tk.Button(window, text='开始执行', width=18, height=1, command=click)
start.pack()
tk.mainloop()