AlwaysOnBottom
108 views
I’m sure you’ve heard of AlwaysOnTop, right? Where the window stays on top of all other windows - always. What if you want the window to be always on the bottom? There is no function for this in the Windows API! This stumped me for a very long time, until I just dove into learning the Windows API entirely. It turns out that you can parent windows to other windows, and this causes them to inherit Z-Order. By finding the desktop window (which is interestingly Program Manager, a throwback to Windows 3.1), you can parent your window to this and achieve an AlwaysOnBottom effect!
I am doing this using Python and pywin32, so here’s a code example in that language (note that all Windows API languages have similar functions and can share much of their code):
import win32gui
window=win32gui.FindWindow(”EXENAME”,”TITLEOFWINDOW”)
win=window.GetSafeHwnd()
desktop=win32gui.FindWindow(’progman’,'Program Manager’)
win32gui.SetParent(win,desktop)
Note: EXENAME does not include the extension “.exe”
I was searching for this code for months in an effort to create a custom Windows shell. I’m sure it would be useful for a number of other applications as well, such as desktop-level apps, media players, custom widgets, etc.
Enjoy, and I hope I spare someone the headache of finding this that I had to go through.
Popularity: 10% [?]
Explore posts in the same categories: scripts, technical, windows