All MicroEvals
Robot Ready! Open Dream11 on Team 1. Press ENTER in this co...
Create MicroEval
Header image for Robot Ready! Open Dream11 on Team 1.

Press ENTER in this co...

Robot Ready! Open Dream11 on Team 1. Press ENTER in this co...

Prompt

Robot Ready! Open Dream11 on Team 1. Press ENTER in this command window to start... --> Processing Team 1 of 40... Found 'Add' row at (174, 522), tapping it. Scroll landed within 3px of expected - fine. --> Processing Team 2 of 40... Found 'Add' row at (174, 519), tapping it. Scroll landed within -2px of expected - fine. --> Processing Team 3 of 40... Found 'Add' row at (174, 514), tapping it. Scroll landed within -6px of expected - fine. --> Processing Team 4 of 40... Found 'Add' row at (174, 510), tapping it. Scroll landed within -9px of expected - fine. --> Processing Team 5 of 40... Found 'Add' row at (174, 507), tapping it. Scroll landed within -12px of expected - fine. --> Processing Team 6 of 40... The real problem is the swipe to the next team. After Save, the code swipes up. But the swipe does not land in the same spot every time. Little by little, the "Add" row moves up and gets more hidden. After 15-20 teams, it is fully hidden. if taht add rows box fr a team si fully hidden then it avoid that team and start the work witht he next team. find the casue and correct teh error and giev teh full code. and in code dont write anything otehr than code. it is not for huamn see or for human read. so dont write anything inside code otehr than code lines. """ Dream11 auto-backup selector for 40 teams. Reads the screen via uiautomator, taps the "Add up to 4 Backups" row if present, picks 4 players, saves, then scrolls to the next team and corrects the scroll if it drifted. """ 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"] # a done row must contain BOTH words MAX_FIND_ATTEMPTS = 5 EXPECTED_TOP_AFTER_SCROLL = 500 SCROLL_SHORTFALL_TOLERANCE = 25 NORMAL_ROW_HEIGHT = 80 SQUEEZE_TOLERANCE = 25 MAX_UNSQUEEZE_ATTEMPTS = 3 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): """One swipe that closes the given pixel gap. Positive offset = row landed too far down (swipe up more). Negative = row drifted too far up (swipe down to bring it back). Capped both ways for safety.""" capped = max(min(offset_pixels, 300), -300) start_y = 700 end_y = max(min(start_y - capped, 1100), 300) subprocess.run(f"adb shell input swipe 608 {start_y} 608 {end_y} 400", 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): """Returns (valid_rows, done_rows) as sorted (left, top, right, bottom) lists. Done rows need BOTH "added" and "edit" so a stray Edit button elsewhere on screen can't get mistaken for a finished team.""" 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(): """Reads the screen up to MAX_FIND_ATTEMPTS times, waiting (never swiping) between tries so a slow-loading screen can settle. Returns ("valid", box), ("done", box), or (None, None).""" 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 process_current_team(): """Taps the Add row if one is found. Returns True only when a valid row was actually tapped.""" row_type, box = find_topmost_row() if row_type == "valid": tap_x, tap_y = box_to_tap_position(box) 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 def scroll_and_correct(): """Scrolls once, checks where the topmost row landed, and sends one signed correction swipe if it's off by more than the tolerance.""" scroll_to_next_team() time.sleep(3) 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(" No row visible yet to measure scroll against - continuing.") return topmost_top = min(box[1] for box in all_rows) offset = topmost_top - EXPECTED_TOP_AFTER_SCROLL if abs(offset) > SCROLL_SHORTFALL_TOLERANCE: direction = "short" if offset > 0 else "drifted up" print(f" Scroll landed {abs(offset)}px {direction} - sending one correction swipe.") correction_swipe(offset) time.sleep(2) else: print(f" Scroll landed within {offset}px of expected - fine.") print("Robot Ready! Open Dream11 on Team 1.") input("Press ENTER in this command window to start...") 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_and_correct() print("ALL 40 TEAMS COMPLETED SUCCESSFULLY!")

Drag to resize
Drag to resize