Erst schauen, dann klicken: aktiver Reiter, offene Tische, Klick nur im Fenster; Tests ohne echten Client
Live 30.10. the bot clicked the Practice tab it was already on and the user saw clicks beside the window. Lobby: read the active tab (.active-tab, measured) and click only if needed, then verify it switched; never Join a table whose window is open (fill and self-heal). A real mouse click is only sent when the point and its scattered end lie inside the target window (KlickAusserhalb, a FensterNichtVorn), and not at all without a lobby window. Two mcp_server_spec tests patched the wrong name and clicked the real lobby with the real mouse whenever CoinPoker ran - they now patch lobby_adapter and demand an opened table; tests/lauf.py blocks the real debug port for every spec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+16
-1
@@ -116,6 +116,16 @@ class FensterNichtVorn(RuntimeError):
|
||||
"""Das Zielfenster kam nicht nach vorn - ein globaler Klick träfe ein fremdes Fenster."""
|
||||
|
||||
|
||||
class KlickAusserhalb(FensterNichtVorn):
|
||||
"""Der Klickpunkt liegt nicht im Zielfenster - ein globaler Klick träfe daneben (live 30.10.)."""
|
||||
|
||||
|
||||
def im_rahmen(x, y, rect):
|
||||
"""Liegt der Punkt im Rahmen (x, y, w, h), Rand eingeschlossen?"""
|
||||
rx, ry, rw, rh = rect
|
||||
return rx <= x <= rx + rw and ry <= y <= ry + rh
|
||||
|
||||
|
||||
def vorne_pid():
|
||||
"""PID der vordersten App (lsappinfo) - None, wenn es sich nicht lesen lässt."""
|
||||
try:
|
||||
@@ -172,10 +182,15 @@ def click(px, py, pid=None, fenster=None, halb=(0.0, 0.0), rng=random):
|
||||
kurz verweilen, drücken, halten, loslassen. Mit `fenster` (aus hand/fenster.py) ist das
|
||||
Fenster vorn, bevor der Zeiger losgeht und noch einmal unmittelbar vor dem Drücken - sonst
|
||||
FensterNichtVorn und kein Klick."""
|
||||
weg, verweilen, halten = maus.plan(zeiger(), (px, py), halb, rng)
|
||||
rect = (fenster or {}).get("rect")
|
||||
if rect: # erst schauen, ob er trifft - dann bewegen
|
||||
for x, y in ((px, py), tuple(weg[-1][1:])):
|
||||
if not im_rahmen(x, y, rect):
|
||||
raise KlickAusserhalb(f"Punkt ({x:.0f}, {y:.0f}) liegt nicht im Fenster {tuple(rect)}")
|
||||
if fenster:
|
||||
pid = fenster.get("pid")
|
||||
vorn_sicherstellen(fenster)
|
||||
weg, verweilen, halten = maus.plan(zeiger(), (px, py), halb, rng)
|
||||
beginn = _time.monotonic()
|
||||
for ms, x, y in weg:
|
||||
warte = beginn + ms / 1000.0 - _time.monotonic()
|
||||
|
||||
Reference in New Issue
Block a user