mirror of
https://github.com/Andre-Bzk/FocusFix.git
synced 2026-11-15 15:43:12 +01:00
Fix: Alt-Taste in finally-Block freigeben
- Wenn bring_to_front() zwischen Alt-DOWN und Alt-UP eine Exception wirft (z.B. ungültiges Handle, fehlende Admin-Rechte), bleibt die Alt-Taste systemweit gedrückt. - Die keybd_event(VK_MENU, ..., KEYEVENTF_KEYUP) Zeile aus dem try-Block in einen finally-Block verschieben, sodass die Alt-Taste immer losgelassen wird.
This commit is contained in:
+2
-2
@@ -141,8 +141,6 @@ def bring_to_front(hwnd: int) -> bool:
|
|||||||
if attached:
|
if attached:
|
||||||
ctypes.windll.user32.AttachThreadInput(tgt_tid, fg_tid, False)
|
ctypes.windll.user32.AttachThreadInput(tgt_tid, fg_tid, False)
|
||||||
|
|
||||||
win32api.keybd_event(win32con.VK_MENU, 0, win32con.KEYEVENTF_KEYUP, 0)
|
|
||||||
|
|
||||||
result = is_foreground(hwnd)
|
result = is_foreground(hwnd)
|
||||||
logging.debug("bring_to_front result: %s (foreground hwnd=%s, target hwnd=%s)",
|
logging.debug("bring_to_front result: %s (foreground hwnd=%s, target hwnd=%s)",
|
||||||
result, win32gui.GetForegroundWindow(), hwnd)
|
result, win32gui.GetForegroundWindow(), hwnd)
|
||||||
@@ -150,6 +148,8 @@ def bring_to_front(hwnd: int) -> bool:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception("bring_to_front failed: %s", e)
|
logging.exception("bring_to_front failed: %s", e)
|
||||||
return False
|
return False
|
||||||
|
finally:
|
||||||
|
win32api.keybd_event(win32con.VK_MENU, 0, win32con.KEYEVENTF_KEYUP, 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user