I'm looking for a way to make another windows applications window to stay 'on top'.
Example:
You have your program/script that is writing some data into an notepad window for the user to read. That notepad window stays on top of everything else while the user can "browse" around in the background without the notepad window highlighted and will still be able to read from it.
So tkinters wm_attributes("-topmost", 1)
wont work since it only affects a window I've created "from scratch".
But it should do the same thing only to another window (p.e. notepad).
This solution requires use of the win32gui
and win32con
modules which are part of the Pywin32 extension.
Providing you already have an instance of the Notepad application running, the following will bring said application to the foreground and keep it there whilst browsing other applications:
import win32gui
import win32con
hwnd = win32gui.FindWindow('Notepad', None)
win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 100, 100, 300, 200, 0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With