Files
mmintel fa08779833 Die Welt ist ein eigener Baum: Projects/pokersim
pokersim (Klon, Cockpit, Ansicht, Leser, Mitschriebe) steht jetzt getrennt neben der Engine.
Der Grund, warum es vorher nicht allein stehen konnte, ist behoben:

  * client/ (Adresse des Clients und seine zwei Sockets) liegt nicht mehr in hand/ - beide Seiten
    finden es ueber die Naht; die Engine braucht dafuer nichts aus der Welt zu importieren
  * die Wurzelmarke aller Dateien ist "lesen" statt "hand": damit findet jede Datei ihre Wurzel,
    egal in welchem der beiden Baeume sie steht (126 Stellen)
  * werkzeuge/hof.py kann beide Baeume bauen: HOF_ART=welt -> Projects/pokersim (Welt),
    ohne -> Projects/pokerfreak-sim (Welt und Engine). Die Welt waehlt ihre Pruefungen nach
    IMPORTEN (Prosa darf die gedockte Engine nennen), der volle Hof nach Erwaehnungen.

Abnahme: Engine-Baum schneller Lauf 1444 Faelle (1 Flatterer, allein gruen); Welt-Baum 38 Pruefungen
333 Faelle rot 0, Bericht 9 Stellen. swift run Pruefung 132 gruen.
2026-11-01 13:26:32 +01:00

96 lines
3.8 KiB
Python

#!/usr/bin/env python3
"""Spricht die Knoepfe des Tischfensters direkt an (macOS-Bedienungshilfen).
Kein Tastenraten, keine blinden Koordinaten: das System nennt uns die Knoepfe
samt Position, wir druecken den gewaehlten.
python3 axpress.py --list # Knoepfe des Tisches auflisten
python3 axpress.py --press 3 # Knopf 3 druecken (AXPress)
python3 axpress.py --click 3 # stattdessen in die Mitte klicken
"""
import os as _os, sys as _sys
_w = _os.path.dirname(_os.path.abspath(__file__))
while _w != "/" and not _os.path.isdir(_os.path.join(_w, "lesen")):
_w = _os.path.dirname(_w)
WURZEL = _w
for _u in ("lesen", "entscheiden", "hand", "client", "lobby", "korpus", "betrieb", "mock"):
_q = _os.path.join(_w, _u)
if _os.path.isdir(_q) and _q not in _sys.path:
_sys.path.insert(0, _q)
import subprocess
import sys
def osa(script):
res = subprocess.run(["osascript", "-e", script], capture_output=True, text=True)
return (res.stdout or res.stderr).strip()
def game_pid():
out = subprocess.run(["pgrep", "-f", "CoinPoker Game"], capture_output=True, text=True)
pids = [int(p) for p in out.stdout.split()]
return pids[0] if pids else None
def main():
pid = game_pid()
if not pid:
print("kein Tischfenster (CoinPoker Game laeuft nicht)")
return 1
proc = f'(first process whose unix id is {pid})'
title = osa(f'tell application "System Events" to tell {proc} to get value of '
f'every static text of window 1')
win = osa(f'tell application "System Events" to tell {proc} to get position of window 1')
size = osa(f'tell application "System Events" to tell {proc} to get size of window 1')
print(f"Prozess {pid}")
print(f"Fenster-Titel: {title}")
print(f"Fenster: {win} Groesse: {size}")
if "--list" in sys.argv or len(sys.argv) == 1:
def nums(text):
return [float(x) for x in text.replace(" ", "").split(",") if x.strip(" ,")]
pos = nums(osa(f'tell application "System Events" to tell {proc} to get position '
f'of every button of window 1'))
dim = nums(osa(f'tell application "System Events" to tell {proc} to get size '
f'of every button of window 1'))
places = list(zip(pos[0::2], pos[1::2]))
sizes = list(zip(dim[0::2], dim[1::2]))
print(f"\nKnöpfe: {len(places)}")
for i, (x, y) in enumerate(places):
w, h = sizes[i] if i < len(sizes) else (0.0, 0.0)
print(f" [{i}] x={x:.0f} y={y:.0f} {w:.0f}x{h:.0f} "
f"Mitte=({x + w / 2:.0f}, {y + h / 2:.0f})")
return 0
index = None
for flag in ("--press", "--click"):
if flag in sys.argv:
index = int(sys.argv[sys.argv.index(flag) + 1])
action = flag
if index is None:
print("bitte --press N oder --click N angeben")
return 1
if action == "--press":
out = osa(f'tell application "System Events" to tell {proc} to perform action '
f'"AXPress" of button {index + 1} of window 1')
print(f"AXPress Knopf {index}: {out or 'gesendet'}")
else:
pos = osa(f'tell application "System Events" to tell {proc} to get position of '
f'button {index + 1} of window 1').split(",")
dim = osa(f'tell application "System Events" to tell {proc} to get size of '
f'button {index + 1} of window 1').split(",")
if len(pos) < 2 or len(dim) < 2:
print(f"Knopf {index} nicht gefunden")
return 1
x = int(float(pos[0])) + int(float(dim[0])) // 2
y = int(float(pos[1])) + int(float(dim[1])) // 2
out = osa(f'tell application "System Events" to click at {{{x}, {y}}}')
print(f"Klick auf Knopf {index} bei {x},{y}: {out or 'gesendet'}")
return 0
if __name__ == "__main__":
sys.exit(main())