Jump to content

So many applications have the ability to make sure that their window is always on bottom. How are they doing it?


Recommended Posts

Has anyone that can understand it seen the source code for something that creates a window that it wants to keep on bottom to see how it's done? I'm at a loss! All I can think of to do is repeatedly set its position to bottom most window, but there has to be a better way, right? 
Doing it my way causes the window to flicker.

A great example of an app that sets and keeps one of its windows always on bottom is any app that wants to write text on the wallpaper. 

Right now, my reason for wanting to do this is to make my own launcher that has buttons, my wifes picture, the ability to play audio... all of that. 

Why is there a way to set windows always on top, but not bottom? 

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to post
Share on other sites

??

; https://www.autoitscript.com/forum/topic/111608-window-always-on-bottom/?do=findComment&comment=782930
; https://www.autoitscript.com/forum/topic/104080-open-winow-in-background/?do=findComment&comment=736679

#include <WinAPI.au3>
$PID = Run("notepad.exe", "", @SW_HIDE) ; run notepad
$handle = _GetHwndFromPID($PID) ; get its handle

; set the parent to the desktop window so when you shownoactivate it is behind all other windows.
$origParent = DllCall("user32.dll", "int", "SetParent", "hwnd", $handle, "hwnd", WinGetHandle("Program Manager"))

; shownoactivate the window (notepad)
; it will stay behind all other windows even when you drag it around
_WinAPI_ShowWindow($handle, @SW_SHOWNOACTIVATE)
; $origParent2 = DllCall("user32.dll", "int", "SetParent", "hwnd", $handle, "hwnd",  $origParent[0])

; https://www.autoitscript.com/forum/topic/86680-pid-window-handle-hwnd-conversion/?do=findComment&comment=621521
Func _GetHwndFromPID($PID)
    $hWnd = 0
    $stPID = DllStructCreate("int")
    Do
        $winlist2 = WinList()
        For $i = 1 To $winlist2[0][0]
            If $winlist2[$i][0] <> "" Then
                DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID))
                If DllStructGetData($stPID, 1) = $PID Then
                    $hWnd = $winlist2[$i][1]
                    ExitLoop
                EndIf
            EndIf
        Next
        Sleep(100)
    Until $hWnd <> 0
    Return $hWnd
EndFunc   ;==>_GetHwndFromPID

 

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...