Skip to content

Commit fe797a6

Browse files
committed
Adding win32_get_hwnd
1 parent e644b52 commit fe797a6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,4 @@ Thumbs.db
110110
# User-specific private settings
111111
*.DotSettings.user
112112
CLAUDE.md
113+
/.claude

PyPI/Package/src/webui/webui.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,21 @@ def set_transparent(self, status: bool) -> None:
13431343
"""
13441344
_raw.webui_set_transparent(c_size_t(self._window), c_bool(status))
13451345

1346+
# -- win32_get_hwnd -----------------------------
1347+
def win32_get_hwnd(self) -> Optional[int]:
1348+
"""Get the Win32 HWND of the window.
1349+
1350+
More reliable than get_hwnd() with WebView than with a browser window,
1351+
as browser PIDs may change on launch. Windows only.
1352+
1353+
Returns:
1354+
Optional[int]: The Win32 HWND as an integer, or None if unavailable.
1355+
1356+
Example:
1357+
hwnd = my_window.win32_get_hwnd()
1358+
"""
1359+
return _raw.webui_win32_get_hwnd(c_size_t(self._window))
1360+
13461361
# -- get_hwnd -----------------------------------
13471362
def get_hwnd(self) -> Optional[int]:
13481363
"""Get the native window handle.
@@ -1681,7 +1696,7 @@ def get_new_window_id() -> int:
16811696
window_id = get_new_window_id()
16821697
print(f"Available window ID: {window_id}")
16831698
"""
1684-
return int(_raw.webui_get_new_window_id)
1699+
return int(_raw.webui_get_new_window_id())
16851700

16861701
# -- is_high_contrast ---------------------------
16871702
def is_high_contrast() -> bool:

0 commit comments

Comments
 (0)