From 9ae32346608218b0b6ce19e4b137a52150f223d1 Mon Sep 17 00:00:00 2001 From: Eswar Balasubramanian Date: Sun, 21 Jan 2024 19:09:29 +0530 Subject: [PATCH 1/3] Windows environment fixes --- bot.py | 2 +- requirements.txt | 2 +- screenshot.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index e935f9c..4e1542e 100644 --- a/bot.py +++ b/bot.py @@ -108,7 +108,7 @@ def run(): max_coords = coords # Check if the maximum value is above a certain threshold - if max_val > 0.95: + if max_val > 0.90: logging.info(f"Image {max_image_file} matches with {max_val * 100}%") # If not ingame reset timer diff --git a/requirements.txt b/requirements.txt index d814dfa..13460b0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -numpy==1.24.1 +numpy==1.26.0 opencv-python==4.7.0.68 diff --git a/screenshot.py b/screenshot.py index b576311..96c77c1 100644 --- a/screenshot.py +++ b/screenshot.py @@ -6,6 +6,6 @@ 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 > {} 2> /dev/null".format(filename) + adb_command = "adb exec-out screencap -p > {}".format(filename) error_code = os.system(adb_command) return error_code == 0 From 0a5b75df88a0db300d1e10b73d5de25e3c18533b Mon Sep 17 00:00:00 2001 From: Eswar Balasubramanian Date: Sun, 21 Jan 2024 21:31:25 +0530 Subject: [PATCH 2/3] max_number_of_games_played_text scenario fix --- bot.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index 4e1542e..ae1b4c2 100644 --- a/bot.py +++ b/bot.py @@ -93,6 +93,7 @@ def run(): max_val = 0 max_image_file = None max_coords = None + max_games_flag = False for image_file, img_template in template_images.items(): result = image_service.find_image(img_screenshot, img_template) if result: @@ -102,13 +103,19 @@ def run(): val, coords = 0, None # Update the maximum value and corresponding image file and coordinates if necessary - if val > max_val: + # if val > max_val: + if ('max_number_of_games_played_text.en.png' == image_file and val > 0.42): + max_val = val + max_image_file = image_file + max_coords = coords + max_games_flag = True + elif (val > max_val and not max_games_flag): max_val = val max_image_file = image_file max_coords = coords # Check if the maximum value is above a certain threshold - if max_val > 0.90: + if max_val > 0.90 or max_games_flag: logging.info(f"Image {max_image_file} matches with {max_val * 100}%") # If not ingame reset timer From 105967108cd826b32ae37a5a216d6b90c09bc3b9 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 3/3] 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