From 2dda92265b020ad5af7c6edf5f709d8257c569c6 Mon Sep 17 00:00:00 2001 From: Ma <101021254+CodeWithMa@users.noreply.github.com> Date: Wed, 24 Jan 2024 17:44:07 +0100 Subject: [PATCH] Check platform.system() to use different adb command for windows --- screenshot.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/screenshot.py b/screenshot.py index 96c77c1..aec47e2 100644 --- a/screenshot.py +++ b/screenshot.py @@ -1,4 +1,5 @@ import os +import platform def capture_screenshot(filename): @@ -6,6 +7,9 @@ def capture_screenshot(filename): Captures a screenshot of the Android screen using adb and saves it to a file. Returns True if the adb command was successful, False otherwise. """ - adb_command = "adb exec-out screencap -p > {}".format(filename) + if platform.system() == "Windows": + adb_command = "adb exec-out screencap -p > {}".format(filename) + else: + adb_command = "adb exec-out screencap -p > {} 2> /dev/null".format(filename) error_code = os.system(adb_command) return error_code == 0