#! /usr/bin/env python
# encoding: utf-8
import pyautogui
import pyperclip
import time
import os
from aip import AipOcr
""" 你的 APPID AK SK """
APP_ID = '***'
API_KEY = '***'
SECRET_KEY = '****'
client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
return fp.read()
def aiWord(filePath=u"D:\\bigemap\\city.jpg"):
""" 读取图片 """
image = get_file_content(filePath)
""" 调用通用文字识别(高精度版) """
result = client.basicAccurate(image)
print(result)
return result['words_result'][0]
pyautogui.PAUSE = 2
pyautogui.FAILSAFE = True
w,h = pyautogui.size()
print(w,h)
time.sleep(3)
def run():
for num in range(0,15):
pyautogui.click(1222,197)
for hi in range(h):
print(hi)
flag = pyautogui.pixelMatchesColor(1220, hi, (90,154,254), tolerance=10)
if flag:
print((1120,hi))
pyautogui.click(1220,hi + 45)
time.sleep(1)
break
pyautogui.screenshot(u"D:\\city.jpg", region=(1183,182,90,30))
word_r = aiWord()
word = word_r["words"]
pyautogui.click(1250,254)
time.sleep(3)
pyperclip.copy(word)
pyautogui.click(145,395)
time.sleep(1)
pyautogui.hotkey('ctrl','v')
pyautogui.click(510,466)
run()