Skip to content

Commit

Permalink
Check platform.system() to use different adb command for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeWithMa committed Jan 31, 2024
1 parent 5725cad commit 2dda922
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion screenshot.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import os
import platform


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

0 comments on commit 2dda922

Please sign in to comment.