import psutil try: import win32gui import win32process except ImportError: win32gui = None win32process = None KNOWN_GAMES = { "VALORANT-Win64-Shipping.exe": "valorant", "League of Legends.exe": "league_of_legends", "csgo.exe": "csgo", "RainbowSix.exe": "rainbow_six_siege", "Overwatch.exe": "overwatch", "Apex.exe": "apex_legends" } def detect_active_game() -> str | None: if not win32gui or not win32process: return None try: hwnd = win32gui.GetForegroundWindow() if not hwnd: return None _, pid = win32process.GetWindowThreadProcessId(hwnd) proc = psutil.Process(pid) exe_name = proc.name() return KNOWN_GAMES.get(exe_name) except (psutil.NoSuchProcess, psutil.AccessDenied): return None except Exception: return None