Always on Top Windows10

Post your working scripts, libraries and tools for AHK v1.1 and older
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Always on Top Windows10

08 May 2020, 16:28

Undocumented CreateWindowInBand.
CreateWindowInBand
This is a private api function found in user32.dll.
CreateWindowInBand function is the same as CreateWindowEx except it has 1 more parameter, dwBand, that is where you specify the band on which the window should stay (ZBID).

HWND WINAPI CreateWindowInBand(
DWORD dwExStyle,
LPCWSTR lpClassName,
LPCWSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam,
DWORD dwBand);
https://blog.adeltax.com/window-z-order-in-windows-10/

Script should be run with UI Access

Code: Select all

#persistent
hwnd := DllCall("CreateWindowInBand", "uint", 0, "str", "Autohotkey", "str", "title", "uint", 0, "int", 0, "int", 0, "int", 200, "int", 200, "ptr", 0, "ptr", 0, "ptr", 0, "ptr", 0, "int", ZBID_UIACCESS := 2, "ptr")
if !a_lasterror
   WinShow ahk_id %hwnd%
else 
   msgbox % a_lasterror
guest3456
Posts: 3469
Joined: 09 Oct 2013, 10:31

Re: Always on Top Windows10

08 May 2020, 20:49

interesting

malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Always on Top Windows10

29 Aug 2021, 22:56

teadrinker detected that when We run script with UIACCESS, then if We set +AlwaysOnTop on Gui then it automatically runs with ZBID_UIACCESS band.

Code: Select all

If !RegExMatch(DllCall("GetCommandLine", "Str"), " /restart(?!\S)")
{
   If (A_PtrSize = 8)
      RunWait "C:\Program Files\AutoHotkey\AutoHotkeyU64_UIA.exe" /restart "%A_ScriptFullPath%"
   Else If A_IsUnicode
      RunWait "C:\Program Files\AutoHotkey\AutoHotkeyU32_UIA.exe" /restart "%A_ScriptFullPath%"
   Else
      RunWait "C:\Program Files\AutoHotkey\AutoHotkeyA32_UIA.exe" /restart "%A_ScriptFullPath%"
}
Gui, +HWNDhGui
Gui, Add, Text,, Please enter your name:
Gui, Add, Edit, vName hwndhEdit
Gui, Show, x0 y0
DllCall("GetWindowBand", "ptr", hGui, "uint*", band)
msgbox % band
Gui, +AlwaysOnTop
DllCall("GetWindowBand", "ptr", hGui, "uint*", band)
msgbox % band

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: william_ahk and 93 guests