我正在尝试让pyautogui读取chrome窗口并基于某个像素的颜色创建窗口警报。当chrome在顶部的窗口中时,我已经可以使用此功能,但是当chrome在其他窗口之后或可能在第二个Desktop上时,我需要使用它。我希望可以使用pyautogui做到这一点,但是我愿意学习其他库。这是我的代码:
from win10toast import ToastNotifier
import time
import pyautogui
toaster = ToastNotifier()
print("Started")
def reload():
pyautogui.click(108,62)
print("reload")
def alert():
print("reading screen")
im = pyautogui.screenshot()
if im.getpixel((495,916)) != (255, 255, 255):
toaster.show_toast("Crowdtap",
"You have a new crowdtap opportunity.",
duration=10)
else:
toaster.show_toast("Nope", "no", duration = 10)
while True:
alert()
time.sleep(180)
reload()
time.sleep(60)