diff --git a/src/ui/character_select.py b/src/ui/character_select.py index 707c4b7..9286b58 100644 --- a/src/ui/character_select.py +++ b/src/ui/character_select.py @@ -236,9 +236,14 @@ def _select_char_by_ocr(char_name: str) -> bool: if result and result[0].text: detected = result[0].text.strip().lower() Logger.debug(f"Row {row}: OCR detected '{detected}'") - # Rows contain extra text (level/class) and OCR noise — a - # substring match is reliable enough for distinct char names. - if char_name_lower == detected or char_name_lower in detected: + # OCR mangles names badly ('fistman' reads as 'fabiman'), so + # fuzzy-match the first word of the row against the char name. + import difflib + first_line = detected.splitlines()[0].strip() if detected else "" + first_word = first_line.split()[0] if first_line.split() else "" + fuzzy_ok = bool(first_word) and difflib.SequenceMatcher( + None, char_name_lower, first_word).ratio() >= 0.6 + if char_name_lower in detected or fuzzy_ok: click_x = x + w // 2 click_y = row_y + row_h // 2 click_pos = convert_screen_to_monitor((click_x, click_y)) diff --git a/start_bot_detached.bat b/start_bot_detached.bat index a822358..626eafe 100644 --- a/start_bot_detached.bat +++ b/start_bot_detached.bat @@ -1,6 +1,9 @@ @echo off -:: Launch botty detached with console output captured to log\console.log +:: Launch botty detached with console output captured to log\console_.log :: (used for unattended/remote starts where no interactive console exists) cd /d "C:\Users\alex\Downloads\my-botty" +:: Single-instance guard: F11/F12 are GLOBAL hotkeys, so two bot instances +:: receive every press and fight each other (one starts, the other pauses). +powershell -NoProfile -Command "Get-CimInstance Win32_Process -Filter \"Name='python.exe'\" | Where-Object {$_.CommandLine -like '*my-botty*main.py*'} | ForEach-Object { Stop-Process -Id $_.ProcessId -Force }" set "TS=%RANDOM%" call "C:\Users\alex\Downloads\my-botty\run_botty.bat" > "C:\Users\alex\Downloads\my-botty\log\console_%TS%.log" 2>&1