HeadlinesBriefing favicon HeadlinesBriefing.com

Fix Chrome PiP Always-on-Top Behavior on Windows

DEV Community •
×

Chrome's Picture-in-Picture (PiP) feature on Windows stubbornly floats above all other windows, blocking full-screen apps or meeting views. A new Python script solves this by programmatically removing the 'always-on-top' attribute from Chrome windows. It uses native Windows APIs via Python's `ctypes` module to identify and modify the `WS_EX_TOPMOST` flag for `chrome.exe` processes.

The utility scans all visible windows, maps them to process IDs, and confirms they belong to Chrome. If a window is flagged as topmost, the script calls `SetWindowPos` with the `HWND_NOTOPMOST` parameter. It employs safe flags like `SWP_NOMOVE` and `SWP_NOACTIVATE` to change only the stacking order without disrupting the user's workspace or stealing focus.

This approach is lightweight and doesn't require administrative privileges, using limited process query permissions. However, it affects all topmost Chrome windows, not just PiP. For developers, it demonstrates practical Windows automation, leveraging the `user32.dll` and `kernel32.dll` APIs to solve a common usability issue with a simple, scriptable solution.