
Robot Ready! Open Dream11 on Team 1. Press ENTER in this com...
Prompt
Robot Ready! Open Dream11 on Team 1. Press ENTER in this command window to start... Row aligned at top=509 (offset 9px). --> Processing Team 1 of 40... Found 'Add' row at (174, 525), tapping it. Row aligned at top=507 (offset 7px). --> Processing Team 2 of 40... Found 'Add' row at (174, 523), tapping it. Row aligned at top=504 (offset 4px). --> Processing Team 3 of 40... Found 'Add' row at (174, 520), tapping it. Row aligned at top=501 (offset 1px). --> Processing Team 4 of 40... Found 'Add' row at (174, 517), tapping it. Row aligned at top=501 (offset 1px). --> Processing Team 5 of 40... Found 'Add' row at (174, 517), tapping it. Row aligned at top=501 (offset 1px). --> Processing Team 6 of 40... Found 'Add' row at (174, 517), tapping it. Row aligned at top=498 (offset -2px). --> Processing Team 7 of 40... Found 'Add' row at (174, 514), tapping it. Row aligned at top=493 (offset -7px). --> Processing Team 8 of 40... Found 'Add' row at (174, 509), tapping it. Row aligned at top=491 (offset -9px). --> Processing Team 9 of 40... Found 'Add' row at (174, 507), tapping it. Row aligned at top=488 (offset -12px). --> Processing Team 10 of 40... Found 'Add' row at (174, 504), tapping it. Row aligned at top=485 (offset -15px). --> Processing Team 11 of 40... Found 'Add' row at (174, 501), tapping it. Row off by -16px - correcting (attempt 1/6). Row aligned at top=492 (offset -8px). --> Processing Team 12 of 40... Found 'Add' row at (174, 508), tapping it. Row aligned at top=491 (offset -9px). --> Processing Team 13 of 40... Found 'Add' row at (174, 507), tapping it. Row aligned at top=486 (offset -14px). --> Processing Team 14 of 40... Found 'Add' row at (174, 502), tapping it. Row off by -17px - correcting (attempt 1/6). Row aligned at top=491 (offset -9px). --> Processing Team 15 of 40... Found 'Add' row at (174, 507), tapping it. Row aligned at top=492 (offset -8px). --> Processing Team 16 of 40... Found 'Add' row at (174, 508), tapping it. Row aligned at top=489 (offset -11px). --> Processing Team 17 of 40... Found 'Add' row at (174, 505), tapping it. Row aligned at top=485 (offset -15px). --> Processing Team 18 of 40... Found 'Add' row at (174, 501), tapping it. Row off by -16px - correcting (attempt 1/6). Row aligned at top=491 (offset -9px). --> Processing Team 19 of 40... Found 'Add' row at (174, 507), tapping it. Row aligned at top=490 (offset -10px). --> Processing Team 20 of 40... Found 'Add' row at (174, 506), tapping it. Row aligned at top=485 (offset -15px). --> Processing Team 21 of 40... Found 'Add' row at (174, 501), tapping it. Row off by -17px - correcting (attempt 1/6). Row aligned at top=490 (offset -10px). --> Processing Team 22 of 40... Found 'Add' row at (174, 506), tapping it. Row aligned at top=487 (offset -13px). --> Processing Team 23 of 40... Found 'Add' row at (174, 503), tapping it. Row aligned at top=487 (offset -13px). --> Processing Team 24 of 40... Found 'Add' row at (174, 503), tapping it. Row off by -17px - correcting (attempt 1/6). Row aligned at top=490 (offset -10px). --> Processing Team 25 of 40... Found 'Add' row at (174, 506), tapping it. Row aligned at top=486 (offset -14px). --> Processing Team 26 of 40... Found 'Add' row at (174, 502), tapping it. Row off by -17px - correcting (attempt 1/6). Row aligned at top=491 (offset -9px). --> Processing Team 27 of 40... Found 'Add' row at (174, 507), tapping it. Row aligned at top=488 (offset -12px). --> Processing Team 28 of 40... Found 'Add' row at (174, 504), tapping it. Row off by -17px - correcting (attempt 1/6). Row aligned at top=490 (offset -10px). --> Processing Team 29 of 40... Found 'Add' row at (174, 506), tapping it. Row aligned at top=485 (offset -15px). --> Processing Team 30 of 40... Found 'Add' row at (174, 501), tapping it. Row aligned at top=486 (offset -14px). --> Processing Team 31 of 40... Found 'Add' row at (174, 502), tapping it. Row aligned at top=485 (offset -15px). --> Processing Team 32 of 40... Found 'Add' row at (174, 501), tapping it. Row off by -17px - correcting (attempt 1/6). Row aligned at top=489 (offset -11px). --> Processing Team 33 of 40... Found 'Add' row at (174, 505), tapping it. Row aligned at top=486 (offset -14px). --> Processing Team 34 of 40... Found 'Add' row at (174, 502), tapping it. Row off by -17px - correcting (attempt 1/6). Row aligned at top=490 (offset -10px). --> Processing Team 35 of 40... Found 'Add' row at (174, 506), tapping it. Row aligned at top=491 (offset -9px). --> Processing Team 36 of 40... Found 'Add' row at (174, 507), tapping it. Row aligned at top=492 (offset -8px). --> Processing Team 37 of 40... Found 'Add' row at (174, 508), tapping it. Row aligned at top=487 (offset -13px). --> Processing Team 38 of 40... Found 'Add' row at (174, 503), tapping it. Row off by 227px - correcting (attempt 1/6). Row off by 227px - correcting (attempt 2/6). Row off by 227px - correcting (attempt 3/6). Row off by 227px - correcting (attempt 4/6). Row off by 227px - correcting (attempt 5/6). Row off by 227px - correcting (attempt 6/6). Warning: could not align row - continuing anyway. --> Processing Team 39 of 40... Found 'Add' row at (174, 749), tapping it. Row off by 679px - correcting (attempt 1/6). Row off by 679px - correcting (attempt 2/6). Row off by 679px - correcting (attempt 3/6). Row off by 679px - correcting (attempt 4/6). Row off by 679px - correcting (attempt 5/6). Row off by 679px - correcting (attempt 6/6). Warning: could not align row - continuing anyway. --> Processing Team 40 of 40... Found 'Add' row at (174, 1195), tapping it. No row visible - recovery down-swipe (1/6). import subprocess import time import re P1_X, P1_Y = 664, 779 P2_X, P2_Y = 664, 932 P3_X, P3_Y = 664, 1073 P4_X, P4_Y = 664, 1212 SAVE_X, SAVE_Y = 487, 1320 VALID_ROW_STARTS_WITH = "add up to" DONE_ROW_KEYWORDS = ["added", "edit"] MAX_FIND_ATTEMPTS = 5 EXPECTED_TOP_AFTER_SCROLL = 500 SCROLL_TOLERANCE = 15 MIN_CORRECTION_PX = 26 MAX_CORRECTION_PX = 320 MAX_CORRECTION_ATTEMPTS = 6 RECOVERY_SWIPE_PX = 240 TAP_SAFE_MIN_Y = 460 TAP_SAFE_MAX_Y = 1240 def tap(x, y): subprocess.run(f"adb shell input tap {x} {y}", shell=True) def scroll_to_next_team(): subprocess.run("adb shell input swipe 608 919 608 465 2000", shell=True) def correction_swipe(offset_pixels): magnitude = abs(int(offset_pixels)) if magnitude < MIN_CORRECTION_PX: magnitude = MIN_CORRECTION_PX if magnitude > MAX_CORRECTION_PX: magnitude = MAX_CORRECTION_PX start_y = 700 end_y = start_y - magnitude if offset_pixels > 0 else start_y + magnitude end_y = max(min(end_y, 1150), 250) duration = max(300, min(900, magnitude * 3)) subprocess.run(f"adb shell input swipe 608 {start_y} 608 {end_y} {duration}", shell=True) def recovery_swipe_down(): subprocess.run(f"adb shell input swipe 608 600 608 {600 + RECOVERY_SWIPE_PX} 700", shell=True) def get_screen_layout_text(): subprocess.run("adb shell uiautomator dump /sdcard/ui_dump.xml", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) subprocess.run("adb pull /sdcard/ui_dump.xml ui_dump.xml", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) try: with open("ui_dump.xml", "r", encoding="utf-8") as f: return f.read() except FileNotFoundError: return "" def find_all_rows(layout_text): pattern = re.compile(r'text="([^"]*)"[^>]*bounds="\[(\d+),(\d+)\]\[(\d+),(\d+)\]"') valid_matches, done_matches = [], [] for match in pattern.finditer(layout_text): text, left, top, right, bottom = match.groups() text_lower = text.strip().lower() if not text_lower: continue box = (int(left), int(top), int(right), int(bottom)) if all(keyword in text_lower for keyword in DONE_ROW_KEYWORDS): done_matches.append(box) elif text_lower.startswith(VALID_ROW_STARTS_WITH): valid_matches.append(box) valid_matches.sort(key=lambda b: b[1]) done_matches.sort(key=lambda b: b[1]) return valid_matches, done_matches def box_to_tap_position(box): left, top, right, bottom = box return (right - 40, (top + bottom) // 2) def find_topmost_row(): for attempt in range(MAX_FIND_ATTEMPTS): layout_text = get_screen_layout_text() valid_rows, done_rows = find_all_rows(layout_text) if valid_rows and done_rows: return ("valid", valid_rows[0]) if valid_rows[0][1] <= done_rows[0][1] else ("done", done_rows[0]) if valid_rows: return ("valid", valid_rows[0]) if done_rows: return ("done", done_rows[0]) print(f" No row visible yet (attempt {attempt + 1}/{MAX_FIND_ATTEMPTS}), waiting...") time.sleep(1) return (None, None) def align_row_to_anchor(): for attempt in range(MAX_CORRECTION_ATTEMPTS): layout_text = get_screen_layout_text() valid_rows, done_rows = find_all_rows(layout_text) all_rows = valid_rows + done_rows if not all_rows: print(f" No row visible - recovery down-swipe ({attempt + 1}/{MAX_CORRECTION_ATTEMPTS}).") recovery_swipe_down() time.sleep(2) continue nearest_top = min(all_rows, key=lambda b: abs(b[1] - EXPECTED_TOP_AFTER_SCROLL))[1] offset = nearest_top - EXPECTED_TOP_AFTER_SCROLL if abs(offset) <= SCROLL_TOLERANCE: print(f" Row aligned at top={nearest_top} (offset {offset}px).") return True print(f" Row off by {offset}px - correcting (attempt {attempt + 1}/{MAX_CORRECTION_ATTEMPTS}).") correction_swipe(offset) time.sleep(2) return False def process_current_team(): row_type, box = find_topmost_row() if row_type == "valid": tap_x, tap_y = box_to_tap_position(box) if tap_y < TAP_SAFE_MIN_Y or tap_y > TAP_SAFE_MAX_Y: print(f" 'Add' row at y={tap_y} outside safe band - skipping this team.") return False print(f" Found 'Add' row at ({tap_x}, {tap_y}), tapping it.") tap(tap_x, tap_y) return True if row_type == "done": print(" Team already has backups - skipping.") return False print(" Could not find any row - skipping this team, no taps made.") return False print("Robot Ready! Open Dream11 on Team 1.") input("Press ENTER in this command window to start...") time.sleep(1) align_row_to_anchor() for team in range(1, 41): print(f"--> Processing Team {team} of 40...") tapped_add = process_current_team() time.sleep(3) if tapped_add: tap(P1_X, P1_Y) time.sleep(0.4) tap(P2_X, P2_Y) time.sleep(0.4) tap(P3_X, P3_Y) time.sleep(0.4) tap(P4_X, P4_Y) time.sleep(0.4) tap(SAVE_X, SAVE_Y) time.sleep(3) else: print(f" Skipping player selection and Save for Team {team}.") scroll_to_next_team() time.sleep(3) if not align_row_to_anchor(): print(" Warning: could not align row - continuing anyway.") print("ALL 40 TEAMS COMPLETED SUCCESSFULLY!") all 40 teams backup got selected, whcih si great. Two things stand out, and neither one has broken your 13 runs β they'd only matter if something on your setup ever shifts. EXPECTED_TOP_AFTER_SCROLL = 500 doesn't know about the end of the list. Near the bottom, the screen can't scroll further, so the row sits somewhere other than 500 for a reason that has nothing to do with drift. The code still treats that as an error and retries 6 times ("off by 227px" etc.) before giving up β it works out because those wasted retries don't move anything on a screen that's already maxed out, but the log still shows failures. No check for "is this actually the end of the list." A simple fix: if two swipes in a row produce the exact same row position, that means the screen physically can't move anymore β the code should recognize that and skip straight to tapping, instead of running the full retry-and-fail cycle every time.