fix: catch SetWindowPos access denied in all window functions

Wraps SetWindowPos in try/except pywintypes.error in move_d2r_window,
set_d2r_always_on_top, and restore_d2r_window_visibility. When D2R runs
as Administrator, Windows denies the call. Bot now continues gracefully
instead of crashing.
This commit is contained in:
alexpolo1
2026-08-07 14:33:07 +02:00
parent 648dc1b25c
commit c5d9fe4541

View File

@@ -184,7 +184,11 @@ def move_d2r_window(client_x, client_y, client_width=None, client_height=None):
outer_y = client_y - (client_top - wr_top)
outer_w = (client_width if client_width else (c_right - c_left)) + border_w
outer_h = (client_height if client_height else (c_bottom - c_top)) + border_h
SetWindowPos(hwnd, HWND_TOPMOST, outer_x, outer_y, outer_w, outer_h, SWP_SHOWWINDOW)
try:
SetWindowPos(hwnd, HWND_TOPMOST, outer_x, outer_y, outer_w, outer_h, SWP_SHOWWINDOW)
except pywintypes.error:
Logger.debug("SetWindowPos denied in move_d2r_window (D2R elevated) — skipping")
return False
Logger.debug(
f"Moved D2R client area to ({client_x}, {client_y}) "
f"with size {client_width or c_right - c_left}x{client_height or c_bottom - c_top}"