mirror of
https://github.com/Andre-Bzk/FocusFix.git
synced 2026-11-15 15:43:12 +01:00
Prozessname automatisch erkennen und titellose Overlay-Fenster ignorieren.
- Prozessname automatisch aus Steam %command% extrahieren (launch.vbs + --process required) - Titellose Overlay-Fenster ignorieren (Wuthering Waves Fix) (Fensterauswahl + Wechsellogik)
This commit is contained in:
+12
-3
@@ -77,7 +77,8 @@ def find_game_window(pids: set[int]) -> int | None:
|
||||
win32gui.EnumWindows(callback, None)
|
||||
if not found:
|
||||
return None
|
||||
found.sort(key=lambda x: x[2] * x[3], reverse=True)
|
||||
# Fenster mit Titel bevorzugen, dann nach Größe sortieren
|
||||
found.sort(key=lambda x: (bool(x[1]), x[2] * x[3]), reverse=True)
|
||||
return found[0][0]
|
||||
|
||||
|
||||
@@ -155,7 +156,8 @@ def bring_to_front(hwnd: int) -> bool:
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--timeout", type=int, default=120)
|
||||
parser.add_argument("--process", type=str, default="CrimsonDesert")
|
||||
parser.add_argument("--process", type=str, required=True,
|
||||
help="Prozessname des Spiels (ohne .exe)")
|
||||
args = parser.parse_args()
|
||||
|
||||
deadline = time.time() + args.timeout
|
||||
@@ -199,8 +201,15 @@ def main() -> None:
|
||||
current_hwnd = find_game_window(pids)
|
||||
|
||||
if current_hwnd and current_hwnd != hwnd:
|
||||
new_title = win32gui.GetWindowText(current_hwnd)
|
||||
old_title = win32gui.GetWindowText(hwnd) if hwnd else ""
|
||||
# Nicht von einem Fenster mit Titel auf ein titelloses wechseln
|
||||
if not new_title and old_title:
|
||||
logging.debug("Ignoring titleless window hwnd=%s (keeping %s title=%r)",
|
||||
current_hwnd, hwnd, old_title)
|
||||
else:
|
||||
logging.info("Window changed: old=%s new=%s title=%r",
|
||||
hwnd, current_hwnd, win32gui.GetWindowText(current_hwnd))
|
||||
hwnd, current_hwnd, new_title)
|
||||
hwnd = current_hwnd
|
||||
focused_hwnd = None # neues Fenster muss neu fokussiert werden
|
||||
time.sleep(1)
|
||||
|
||||
+7
-1
@@ -1,7 +1,13 @@
|
||||
Set WshShell = CreateObject("WScript.Shell")
|
||||
|
||||
' Prozessname aus dem ersten Argument (Steam %command%) extrahieren
|
||||
Dim exePath, fso, exeName
|
||||
Set fso = CreateObject("Scripting.FileSystemObject")
|
||||
exePath = WScript.Arguments(0)
|
||||
exeName = fso.GetBaseName(exePath)
|
||||
|
||||
' Foreground-Fix Script unsichtbar starten (pythonw = kein Konsolenfenster)
|
||||
WshShell.Run """C:\Projekte\Steam_backgroud_fix\.venv\Scripts\pythonw.exe"" ""C:\Projekte\Steam_backgroud_fix\foreground_fix.py""", 0, False
|
||||
WshShell.Run """C:\Projekte\Steam_backgroud_fix\.venv\Scripts\pythonw.exe"" ""C:\Projekte\Steam_backgroud_fix\foreground_fix.py"" --process """ & exeName & """", 0, False
|
||||
|
||||
' Spiel starten: alle Argumente (= Steam %command%) zusammensetzen und ausführen
|
||||
Dim gameCmd, i
|
||||
|
||||
Reference in New Issue
Block a user