|
上图是 PIDT_Main.py的代码,我现在上传PIDT_Step_Three.py的代码
import threading, time
import pyautogui
from PIL import Image
def delay_s():
print(time.time())
Step_Three_OK = False
def Step_Three():
"""
PIDT操作第三步,通过截图查看颜色是否为红色(REB),不是红色,一直在循环
"""
REB = [0, 0, 0]
Step3Counter = 0;
print(REB)
#im = pyautogui.screenshot()
#Image._show(im) #查看所截图的图片
#REB = im.getpixel((46, 195))
#print(im.getpixel((46, 195)))
#print(REB[0])
while True:
pyautogui.click()
im = pyautogui.screenshot()
# Image._show(im) #查看所截图的图片
REB = im.getpixel((46, 195))
if REB[0] != 153:
pyautogui.moveTo(713, 344)
#print(im.getpixel((46, 195)))
#print(REB[0])
s = threading.Timer(1, delay_s) # 1s时基,循环10次 用线程做的延时
s.start()
Step3Counter = Step3Counter + 1
#print(Step3Counter)
if Step3Counter > 10:
break
Step_Three_OK = False
else:
Step_Three_OK = True
break
Step_Three_OK = True
print(Step_Three_OK)[/code] |
|