当img弹出时,Python在某处单击

2024-09-30 03:25:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我想写一个关于图像可能随时弹出的程序,操作是关闭图像,而不是点击图像。我有一些关于代码的想法,但不成功:(图像不是弹出式的,但仍要等待1秒钟,然后单击右上角的conner…)

{<1分$ import pyautogui, time while ture: pyautogui.click(pyautogui.center(pyautogui.locateOnScreen(r'C:\Users\Lawrence\Desktop\PyTest\image.png'))) time.sleep(1) #I want to check image every sec break pyautogui.click(1880,15) # after checking the screen for every sec, the image popup, and click top right conner to close it, finish
你知道吗?谢谢你

Tags: theto代码图像imageimport程序time
1条回答
网友
1楼 · 发布于 2024-09-30 03:25:39

试试这个。你太早就打破了,点击了错误的东西。在

import pyautogui, time
while True:
    #I want to check image every sec
    time.sleep(.1) #put time interval for checking here
    if pyautogui.locateOnScreen(r'C:\Users\Lawrence\Desktop\PyTest\image.png'):
       pyautogui.click(1880,15)  
       break

相关问题 更多 >

    热门问题