import tkinter as tk
import threading
import time
import pyautogui
import pyperclip

running = False
log_text = None

更改后的路径

BASE_PATH = ‘C:/Users/Administrator/Desktop/yunduanxuexi/’

def locate_and_click(image_name, confidence=0.9, center=True):
image_path = BASE_PATH + image_name
location = pyautogui.locateCenterOnScreen(image_path, confidence=confidence) if center else pyautogui.locateOnScreen(image_path, confidence=confidence)
if location:
pyautogui.click(location)
log(f”点击了 {image_name}”)
return True
else:
log(f”未找到 {image_name}”)
return False

def drag(start, end, duration=1.0):
pyautogui.moveTo(start) pyautogui.mouseDown() pyautogui.moveTo(end, duration=duration)
pyautogui.mouseUp()

def read_accounts():
with open(BASE_PATH + ‘zhanghao.txt’, ‘r’, encoding=’utf-8′) as f:
lines = [line.strip() for line in f if line.strip()]
return [(lines[i], lines[i+1]) for i in range(0, len(lines), 2)]

def read_params():
with open(BASE_PATH + ‘shuzu.txt’, ‘r’, encoding=’utf-8′) as f:
content = f.read().strip()
return [(int(x), int(y)) for x, y in (item.split(‘,’) for item in content.split(‘;’))]

def input_text(text):
pyperclip.copy(text)
pyautogui.hotkey(‘ctrl’, ‘v’)

def run_learning():
global running
accounts = read_accounts()
params = read_params()

for idx, (user, pwd) in enumerate(accounts):
    if not running:
        break
    log(f"开始账号:{user}")

    locate_and_click('00.jpg')
    time.sleep(1)
    pyautogui.press('enter')
    time.sleep(3)
    pyautogui.hotkey('win', 'up')
    locate_and_click('01.jpg')
    pyautogui.hotkey('ctrl', 'a')
    input_text("https://pc.kmelearning.com/jsncxyslhs/home/login")
    pyautogui.press('enter')
    pyautogui.press('enter')
    time.sleep(5)
    pyautogui.click(1307, 292)
    time.sleep(1)
    pyautogui.hotkey('ctrl', 'a')
    time.sleep(1)
    input_text(user)
    time.sleep(0.5)
    pyautogui.press('tab')
    time.sleep(0.5)
    input_text(pwd)
    time.sleep(0.5)
    drag((997, 435), (1318, 435))
    time.sleep(0.5)
    pyautogui.click(990, 533)
    time.sleep(0.5)
    locate_and_click('02.jpg')
    time.sleep(5)

    for i in range(1, 11):
        if locate_and_click(f"{i}.jpg"):
            time.sleep(3)
        else:
            break

    for i, (interval, count) in enumerate(params):
        img = f"{21 + i}.jpg"
        if locate_and_click(img):
            time.sleep(4)
            pyautogui.moveTo(768, 555)
            time.sleep(1)
            pyautogui.click()
            for _ in range(count):
                if not running:
                    break
                time.sleep(interval * 60)
                pyautogui.click()
            time.sleep(3)
            pyautogui.hotkey('ctrl', 'shift', 'w')
            time.sleep(3)
        else:
            break

    log(f"账号 {user} 完成")
log("所有账号运行结束")
running = False

def log(text):
log_text.insert(tk.END, f”{time.strftime(‘%H:%M:%S’)} – {text}\n”)
log_text.see(tk.END)
print(text)

def start():
global running
if not running:
running = True
log(“开始运行”)
threading.Thread(target=run_learning, daemon=True).start()

def stop():
global running
running = False
log(“停止运行”)

def build_gui():
global log_text
window = tk.Tk()
window.title(“云端学习控制面板”)
window.geometry(“600×400”)

tk.Button(window, text="开始运行", font=("Arial", 14), command=start).pack(pady=10)
tk.Button(window, text="停止运行", font=("Arial", 14), command=stop).pack(pady=10)

log_text = tk.Text(window, height=15, wrap=tk.WORD)
log_text.pack(fill=tk.BOTH, expand=True)

window.mainloop()

if name == “main“:
build_gui()


发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注