fix: fuzzy char-name OCR match; single-instance guard in detached launcher

- OCR reads FISTMAN as "fabiman" — SequenceMatcher >= 0.6 on the first
  word of the row handles the mangling
- start_bot_detached.bat kills existing main.py instances first: F11/F12
  are global hotkeys, so duplicate bots receive every press and fight
  each other (one starts while the other pauses/exits)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
alex
2026-06-10 18:28:12 +02:00
parent f410ea21f1
commit 06c73e7cbf
2 changed files with 12 additions and 4 deletions

View File

@@ -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))

View File

@@ -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_<rand>.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