# 安装pyautogui
# pip install -i https://mirrors.aliyun.com/pypi/simple/ pyautogui==0.9.54
# pip install -i https://mirrors.aliyun.com/pypi/simple/ opencv-python==4.6.0.66
import pyautogui
import time
from cnocr import CnOcr
print("请将鼠标移动到开始坐标……")
start=time.time()
while True:
s=pyautogui.position()
if time.time()-start>=2:
break
print("开始坐标为:", s)
print("请将鼠标移动到结束坐标……")
end=time.time()
while True:
e=pyautogui.position()
if time.time()-end>=3:
break
print("结束坐标为:", e)
r=[min(s[0],e[0]),min(s[1],e[1]),
abs(s[0]-e[0]),abs(s[1]-e[1])]
x=pyautogui.screenshot('jt.png',region=r)
a=CnOcr()
b=a.ocr('jt.png')
for i in b:
print(i["text"])
print("请将鼠标移动到输入位置……")
yzm_time=time.time()
while True:
y=pyautogui.position()
if time.time()-yzm_time>=3:
break
print("结束坐标为:", y)
pyautogui.click(y)
pyautogui.write(i["text"])
# import pyperclip
# pyperclip.copy('text')
# pyperclip.paste()
print(type(b))
time.sleep(2)
pyautogui.hotkey('enter')