python --versionpip install Pillow opencv-python nếu cần xử lý ảnh màn hìnhadb devices hoạt động từ CMDimport subprocess def get_devices(): result = subprocess.run( ["adb", "devices"], capture_output=True, text=True ) devices = [] for line in result.stdout.splitlines()[1:]: if "device" in line and "offline" not in line: devices.append(line.split()[0]) return devices devices = get_devices() print(f"Đang kết nối: {len(devices)} máy") for d in devices: print(f" → {d}")
import subprocess, time, random def run_all(cmd, min_delay=0.5, max_delay=3.0): devices = get_devices() for serial in devices: full_cmd = ["adb", "-s", serial, "shell"] + cmd subprocess.run(full_cmd, capture_output=True) delay = random.uniform(min_delay, max_delay) time.sleep(delay) # Random delay = hành vi tự nhiên hơn print(f"✅ Đã chạy trên {len(devices)} máy") # Ví dụ: Tắt màn hình tất cả máy run_all(["settings", "put", "system", "screen_brightness", "0"])
def check_temps(warn_threshold=45000): devices = get_devices() hot = [] for serial in devices: r = subprocess.run( ["adb","-s",serial,"shell", "cat /sys/class/thermal/thermal_zone0/temp"], capture_output=True, text=True ) try: temp = int(r.stdout.strip()) if temp > warn_threshold: hot.append((serial, temp/1000)) except: pass if hot: print("⚠️ Máy quá nóng:") for s, t in hot: print(f" {s}: {t}°C") else: print("✅ Nhiệt độ bình thường")
Để script chạy tự động lúc 3h sáng mỗi ngày mà không cần mở máy tính:
Hoàn toàn được. Chỉ cần học Python cơ bản trong 2–3 tuần (khóa miễn phí trên YouTube hoặc freeCodeCamp). Sau đó copy và chỉnh sửa các script mẫu phổ biến trong cộng đồng. Không cần học thuật toán hay data structure phức tạp.
Có, dùng thư viện threading hoặc multiprocessing của Python. Tuy nhiên với farm dưới 50 máy, chạy tuần tự với delay ngẫu nhiên thường đủ dùng và đơn giản hơn nhiều so với lập trình đa luồng.
Hỗ trợ 24/7 – Tư vấn miễn phí qua Zalo