capture.py 448 B

123456789101112131415161718
  1. import datetime
  2. from ppadb.client import Client as AdbClient
  3. client = AdbClient(host="127.0.0.1", port=5037)
  4. device = client.device("192.168.178.32:5555")
  5. def save_screenshot():
  6. # Take a screenshot
  7. result = device.screencap()
  8. timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
  9. filename = f"fights/{timestamp}.png"
  10. # Save the screenshot to a file
  11. with open(filename, "wb") as fp:
  12. fp.write(result)
  13. save_screenshot()