I know that winset, bottom command gets the job done but sometimes a certain program has bullt-in behaviors of ignoring that script, so it pops back up time to time.
I want a program to be at the bottommost and stay like that until I press hotkey to cancel it.
is there a way to override all other attempts to get out of bottom mode for a program?
how to keep a window at the bottom always?
Re: how to keep a window at the bottom always?
Just in case it helps, there is an AlwaysOnTop subcommand for WinSet.
You could set 'always on top' to off, for a window you want to be bottommost.
WinSet - Syntax & Usage | AutoHotkey
https://autohotkey.com/docs/commands/WinSet.htm
You could set 'always on top' to off, for a window you want to be bottommost.
WinSet - Syntax & Usage | AutoHotkey
https://autohotkey.com/docs/commands/WinSet.htm
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: how to keep a window at the bottom always?
Hi tatagi,
Would you let me know if the following code solves your problem?Cheers!
- iPhilip
Would you let me know if the following code solves your problem?
Code: Select all
#NoEnv
WinIDs := GetAltTabWindows()
BottomID := WinIDs.Pop() ; Get the bottom-most window
DllCall("RegisterShellHookWindow", "Ptr", A_ScriptHwnd)
MsgNum := DllCall("RegisterWindowMessage", "Str", "SHELLHOOK")
OnMessage(MsgNum, "ShellMessage")
Return
ShellMessage(wParam, lParam) {
global BottomID
if (wParam = 0x0004 ; HSHELL_WINDOWACTIVATED = 0x0004 = 4
|| wParam = 0x8004) ; HSHELL_RUDEAPPACTIVATED = HSHELL_WINDOWACTIVATED | HSHELL_HIGHBIT = 0x0004 | 0x8000 = 0x8004 = 32772
WinSet, Bottom, , ahk_id %BottomID%
}
F3:: ; Disable monitoring of window activation
OnMessage(MsgNum, "")
Return
; https://autohotkey.com/board/topic/21657-alttab-window-list-get-a-list-of-alt-tab-windows/?p=600122
GetAltTabWindows() {
static GW_OWNER := 4, WS_EX_TOOLWINDOW := 0x80, WS_EX_APPWINDOW := 0x40000
PrevDetectHiddenWindows := A_DetectHiddenWindows
DetectHiddenWindows, Off
Windows := []
WinGet, ID, List, , , Program Manager
Loop, %ID% {
OwnerID := ID%A_Index%
Loop
OwnerID := DllCall("GetWindow", "Ptr", OwnerID, "UInt", GW_OWNER, "Ptr")
Until !DllCall("GetWindow", "Ptr", OwnerID, "UInt", GW_OWNER, "Ptr")
OwnerID := OwnerID ? OwnerID : ID%A_Index%
if (DllCall("GetLastActivePopup", "Ptr", OwnerID, "Ptr") = ID%A_Index%) {
WinGet, ExStyle, ExStyle, % "ahk_id " ID%A_Index%
if !((ExStyle & WS_EX_TOOLWINDOW) && !(ExStyle & WS_EX_APPWINDOW))
Windows.Push(ID%A_Index%)
}
}
DetectHiddenWindows, %PrevDetectHiddenWindows%
Return Windows
}
- iPhilip
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
-
- Posts: 1
- Joined: 16 Sep 2022, 09:53
Re: how to keep a window at the bottom always?
Thanks iPhilip.
The code is great!!!
The code is great!!!
Re: how to keep a window at the bottom always?
@SkywardAxe, Happy to hear that it's useful to you.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Re: how to keep a window at the bottom always?
How do you use this script?iPhilip wrote: ↑09 Apr 2019, 15:03Cheers!Code: Select all
#NoEnv WinIDs := GetAltTabWindows() BottomID := WinIDs.Pop() ; Get the bottom-most window DllCall("RegisterShellHookWindow", "Ptr", A_ScriptHwnd) MsgNum := DllCall("RegisterWindowMessage", "Str", "SHELLHOOK") OnMessage(MsgNum, "ShellMessage") Return ShellMessage(wParam, lParam) { global BottomID if (wParam = 0x0004 ; HSHELL_WINDOWACTIVATED = 0x0004 = 4 || wParam = 0x8004) ; HSHELL_RUDEAPPACTIVATED = HSHELL_WINDOWACTIVATED | HSHELL_HIGHBIT = 0x0004 | 0x8000 = 0x8004 = 32772 WinSet, Bottom, , ahk_id %BottomID% } F3:: ; Disable monitoring of window activation OnMessage(MsgNum, "") Return ; https://autohotkey.com/board/topic/21657-alttab-window-list-get-a-list-of-alt-tab-windows/?p=600122 GetAltTabWindows() { static GW_OWNER := 4, WS_EX_TOOLWINDOW := 0x80, WS_EX_APPWINDOW := 0x40000 PrevDetectHiddenWindows := A_DetectHiddenWindows DetectHiddenWindows, Off Windows := [] WinGet, ID, List, , , Program Manager Loop, %ID% { OwnerID := ID%A_Index% Loop OwnerID := DllCall("GetWindow", "Ptr", OwnerID, "UInt", GW_OWNER, "Ptr") Until !DllCall("GetWindow", "Ptr", OwnerID, "UInt", GW_OWNER, "Ptr") OwnerID := OwnerID ? OwnerID : ID%A_Index% if (DllCall("GetLastActivePopup", "Ptr", OwnerID, "Ptr") = ID%A_Index%) { WinGet, ExStyle, ExStyle, % "ahk_id " ID%A_Index% if !((ExStyle & WS_EX_TOOLWINDOW) && !(ExStyle & WS_EX_APPWINDOW)) Windows.Push(ID%A_Index%) } } DetectHiddenWindows, %PrevDetectHiddenWindows% Return Windows }
- iPhilip
I mean, do you click on the window and then press a certain key combo, like with the more well-known "alwaysontop" function? I don't see that in the code, so I am wondering how it determines which window to act on?
I am currently running Ubuntu with desktop in WSL2 on Windows 11, and I would like to set the Ubuntu window to always on bottom, so the desktop doesn't cover the Windows apps that I have open.
I can get the same result by setting each individual Windows app to "alwaysontop", but it is somewhat tedious.
Re: how to keep a window at the bottom always?
@shmu26 When you run the script, the current bottom-most window will remain at the bottom, no matter which window you select. The OnMessage command monitors the selection of any desktop window. When a window is selected, the original bottom-most window is send to the bottom. The F3 hotkey turns off the monitoring.shmu26 wrote: ↑08 Apr 2024, 08:56How do you use this script?
I mean, do you click on the window and then press a certain key combo, like with the more well-known "alwaysontop" function? I don't see that in the code, so I am wondering how it determines which window to act on?
I am currently running Ubuntu with desktop in WSL2 on Windows 11, and I would like to set the Ubuntu window to always on bottom, so the desktop doesn't cover the Windows apps that I have open.
I can get the same result by setting each individual Windows app to "alwaysontop", but it is somewhat tedious.
I hope this helps to clarify things.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Re: how to keep a window at the bottom always?
Here's a simpler version that doesn't use the GetAltTabWindows function (which is buggy):
The F2 hotkey send the active window to the bottom and keeps it there. The F3 hotkey disables that.
Code: Select all
#NoEnv
DllCall("RegisterShellHookWindow", "Ptr", A_ScriptHwnd)
MsgNum := DllCall("RegisterWindowMessage", "Str", "SHELLHOOK")
return
F2::
BottomID := WinExist("A")
WinSet, Bottom, , ahk_id %BottomID%
OnMessage(MsgNum, "ShellMessage")
Return
F3:: ; Disable monitoring of window activation
OnMessage(MsgNum, "")
Return
ShellMessage(wParam) {
global BottomID
if (wParam = 0x0004 ; HSHELL_WINDOWACTIVATED = 0x0004 = 4
|| wParam = 0x8004) ; HSHELL_RUDEAPPACTIVATED = HSHELL_WINDOWACTIVATED | HSHELL_HIGHBIT = 0x0004 | 0x8000 = 0x8004 = 32772
WinSet, Bottom, , ahk_id %BottomID%
}
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Re: how to keep a window at the bottom always?
Thanks! Will this work on the old version of AHK?
Answer: Yes. This is a great script!
Answer: Yes. This is a great script!
Re: how to keep a window at the bottom always?
Perfect. Works also on the old version of AHK.iPhilip wrote: ↑08 Apr 2024, 19:52Here's a simpler version that doesn't use the GetAltTabWindows function (which is buggy):
The F2 hotkey send the active window to the bottom and keeps it there. The F3 hotkey disables that.Code: Select all
#NoEnv DllCall("RegisterShellHookWindow", "Ptr", A_ScriptHwnd) MsgNum := DllCall("RegisterWindowMessage", "Str", "SHELLHOOK") return F2:: BottomID := WinExist("A") WinSet, Bottom, , ahk_id %BottomID% OnMessage(MsgNum, "ShellMessage") Return F3:: ; Disable monitoring of window activation OnMessage(MsgNum, "") Return ShellMessage(wParam) { global BottomID if (wParam = 0x0004 ; HSHELL_WINDOWACTIVATED = 0x0004 = 4 || wParam = 0x8004) ; HSHELL_RUDEAPPACTIVATED = HSHELL_WINDOWACTIVATED | HSHELL_HIGHBIT = 0x0004 | 0x8000 = 0x8004 = 32772 WinSet, Bottom, , ahk_id %BottomID% }
Re: how to keep a window at the bottom always?
Great!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Who is online
Users browsing this forum: Google [Bot] and 152 guests