Files
mmintelandClaude Opus 4.8 cc7148f8b8 Windows-Port: Leerlauf-Takt entstockt + nativer Prozessleser + frische Sitz-Reserve (WIP)
- winproc: Kommandozeilen nativ (Toolhelp32 + NtQueryInformationProcess/PEB)
  statt WMI/PowerShell - ~43 ms statt ~10 s je Abfrage (100x), WMI nur noch
  als Rueckfall. Das war die Hauptquelle des 35-53-s-Zyklus.
- tischkanal/runner: echo=False (feuern-und-vergessen) fuer die OHNE_ECHO-
  Zustandsbefehle (play_next/auto_post_bb/aussetzen/aufstehen/nachkauf) - kein
  1,5-s-Leerwarten mehr je Leerlauf-Takt (offline bewiesen 1519 ms -> 0 ms).
- runner: Sitz-TTL-Rennen - unmittelbar vor take_Seat frisch reservieren und
  den vom Server bestaetigten Sitz nehmen; Flut-Deckel ueber Prozesszahl statt
  Fensterzahl. Live bewiesen (Held sitzt, spielt, gewinnt).
- hand/foto,mittler,notaus,press,sitzwache + werkzeuge/hover: Windows-Rand.
- Tests: auffuellen_kappe_spec, sitz_reserve_frisch_spec (neu) + Anpassungen.

WIP: Rest-Tail ~18% der Zuege >1 s Maschinenzeit noch offen; 12-Tisch-Last
noch nicht gemessen.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-12 16:08:41 +01:00

77 lines
2.9 KiB
Python

#!/usr/bin/env python3
"""Tastendruck an das Tischfenster senden - ohne den Fokus zu klauen.
python3 press.py --trust # ist die Bedienungshilfen-Freigabe erteilt?
python3 press.py f # Taste 'f' an CoinPoker Game senden
python3 press.py --global f # stattdessen an das vorderste Fenster
"""
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"):
_q = _os.path.join(_w, _u)
if _os.path.isdir(_q) and _q not in _sys.path:
_sys.path.insert(0, _q)
import ctypes
import subprocess
import sys
FW = "/System/Library/Frameworks/ApplicationServices.framework/ApplicationServices"
# Mac-Backend (CGEvent via ApplicationServices). Unter Windows laeuft der Kanalbetrieb mit Maus AUS -
# hier NICHTS laden, sonst stirbt schon der Import (die Framework-Datei fehlt). Wie hand/click.py:41.
AS = ctypes.cdll.LoadLibrary(FW) if sys.platform == "darwin" else None
if AS is not None:
AS.AXIsProcessTrusted.restype = ctypes.c_bool
AS.CGEventCreateKeyboardEvent.restype = ctypes.c_void_p
AS.CGEventCreateKeyboardEvent.argtypes = [ctypes.c_void_p, ctypes.c_uint16, ctypes.c_bool]
AS.CGEventPostToPid.argtypes = [ctypes.c_int, ctypes.c_void_p]
AS.CGEventPost.argtypes = [ctypes.c_uint32, ctypes.c_void_p]
# macOS Virtuelle Tastencodes
KEYS = {
"a": 0, "s": 1, "d": 2, "f": 3, "h": 4, "g": 5, "z": 6, "x": 7, "c": 8, "v": 9,
"b": 11, "q": 12, "w": 13, "e": 14, "r": 15, "y": 16, "t": 17, "o": 31, "u": 32,
"i": 34, "p": 35, "l": 37, "j": 38, "k": 40, "n": 45, "m": 46,
"1": 18, "2": 19, "3": 20, "4": 21, "5": 23, "6": 22, "7": 26, "8": 28, "9": 25,
"0": 29, "space": 49, "enter": 36, "esc": 53, "tab": 48,
}
def main():
while True:
out = subprocess.run(["pgrep", "-f", "CoinPoker Game"], capture_output=True, text=True)
pids = [int(x) for x in out.stdout.split()]
if not pids:
print("kein Tischfenster gefunden (CoinPoker Game laeuft nicht)")
sys.exit(1)
break
args = sys.argv[1:]
if not args or args[0] == "--trust":
print("Bedienungshilfen-Freigabe erteilt:", AS.AXIsProcessTrusted())
print("Tisch-Prozesse:", pids)
sys.exit(0)
global_mode = args[0] == "--global"
key = args[-1]
code = KEYS.get(key.lower())
if code is None:
print(f"unbekannte Taste {key!r}; bekannt: {sorted(KEYS)}")
sys.exit(1)
for down in (True, False):
event = AS.CGEventCreateKeyboardEvent(None, code, down)
if global_mode:
AS.CGEventPost(0, event)
else:
for pid in pids:
AS.CGEventPostToPid(pid, event)
print(f"Taste {key!r} (code {code}) gesendet an {pids}"
f"{' (global)' if global_mode else ' (an Prozess)'}")
if __name__ == "__main__":
main()