📋 Luồng thực tế
GET /health— app sống.GET /scripts— đúngname.GET /exes?process=dnplayer.exe(hoặc/windows?q=ldplayer) — còn đủ cửa sổ,alive, kích thước client đúng với lúc cắt ảnh.POST /scripts/{name}/start-mtvớiwindows+max_threads+variables.- Poll
GET /scripts/{name}/statusđếnrunning: false(hoặcrunning_count == 0). Hàngqueuedsẽ tự lên khi slot trống. - Lỗi một máy →
POST /scripts/{name}/stopvớihwndđó; các luồng khác vẫn chạy. - Dừng gấp →
POST /run/stop.
Biến trên node Bắt đầu phải khai báo tên; giá trị điền ở Cài đặt kịch bản hoặc variables trong API. Chi tiết: Khai báo biến.
Lưu ý vận hành
- Tool phải mở — thoát app thì API tắt.
- Chỉ localhost — máy khác không gọi được (không khuyến nghị forward port).
- Đổi port — sửa URL trong script tích hợp.
- File kịch bản:
data/scripts/*.apc— tạo/import trên UI trước. - Đa luồng API không bật lịch hẹn giờ; lịch vẫn do UI.
variablesAPI ghi đè biến đã lưu, không ghi đè file.apc. queuedchỉ sống khi app còn mở. Restart app = mất hàng đợi.- Node Chọn App trong script: khi API đã bind HWND, runner giữ cửa sổ đó (không nhảy instance khác).
Python: check exe → đa luồng → poll → stop một máy
import time
import requests
BASE = "http://127.0.0.1:8765/api/v1"
NAME = "NhiemVuNgay"
def api(method, path, **kw):
r = requests.request(method, BASE + path, timeout=30, **kw)
r.raise_for_status()
return r.json()
assert api("GET", "/health").get("ok")
exes = api("GET", "/exes", params={"process": "dnplayer.exe"})["exes"]
windows = exes[0]["windows"] if exes else []
assert windows, "Không thấy dnplayer"
api("POST", f"/scripts/{NAME}/start-mt", json={
"windows": windows,
"max_threads": min(3, len(windows)),
"variables": {"taikhoan": "acc01"},
})
for _ in range(600):
st = api("GET", f"/scripts/{NAME}/status")
if not st["running"]:
print("xong")
break
time.sleep(1)
else:
api("POST", "/run/stop")