Skip to content

Commit

Permalink
Add toggle_cloak method to window_dwm class for window invisibility c…
Browse files Browse the repository at this point in the history
…ontrol
  • Loading branch information
Zingzy committed Jan 12, 2025
1 parent c2467b8 commit 1a710e6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions hPyT/hPyT.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ctypes.wintypes
import math
import threading
import time
Expand Down Expand Up @@ -1367,6 +1368,39 @@ def toggle_rtl_layout(cls, window: Any, enabled: bool = True) -> None:
4,
)

@classmethod
def toggle_cloak(cls, window: Any, enabled: bool = True) -> None:
"""
Toggle window cloaking (invisibility while still being composed by DWM).
Useful for DirectComposition animations and special effects.
Note: Only supported on Windows 8 and later.
Args:
window (object): The window object to modify.
enabled (bool): True to cloak (hide) the window, False to uncloak (show).
Example:
# Cloak (hide) the window
>>> window_dwm.toggle_cloak(window, True)
# Uncloak (show) the window
>>> window_dwm.toggle_cloak(window, False)
Notes:
- Window remains composed by DWM even when cloaked
- Particularly useful with DirectComposition for layered child window animations
- Does not affect window functionality, only visibility
"""
hwnd: int = module_find(window)

# DWMWA_CLOAK = 13
ctypes.windll.dwmapi.DwmSetWindowAttribute(
hwnd,
13, # DWMWA_CLOAK
ctypes.byref(ctypes.wintypes.BOOL(enabled)),
ctypes.sizeof(ctypes.wintypes.BOOL(enabled)),
)


class title_text:
"""Play with the title of a window."""
Expand Down

0 comments on commit 1a710e6

Please sign in to comment.