Always showing a window above standard 'on top' windows

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ralf_Reddings200244
Posts: 110
Joined: 11 Mar 2023, 14:16

Always showing a window above standard 'on top' windows

Post by Ralf_Reddings200244 » 24 May 2024, 17:47

I have two windows that I always need to be unobscured, even against windows that have alwaysOnTop.

The alwayOnTop subcommand is not full proof, for example if another window that also has alwaysOnTop happens to be active, it can obscure a window that also has alwaysOnTop, and then there are system windows (start, notifications) that seem to be above standard 'on top' windows

Searching a round there seems to be a way to do this, something to do with "zband" but its not well known and its to do with DLL calls, something I don't know much about.

Apparently a few people figured out it, for example @malcev and @teadrinker

I tried to rework malcev's example, Alaways on Top Windows 10, and test it on a notepad window:

Code: Select all

hwnd := DllCall("CreateWindowInBand", "uint", 0, "str", "Notepad", "str", "Untitled - Notepad", "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
But when I run the code with a UI access interpreter, I keep getting a 1407 error, from searching around this is a "class not found error", but Spy says the class is Notepad...

I have tried to solve this on my own but examples are sparse and I am not getting anywhere, I would appreciate any pointers or solutions. Thanks.

teadrinker
Posts: 4412
Joined: 29 Mar 2015, 09:41
Contact:

Re: Always showing a window above standard 'on top' windows

Post by teadrinker » 25 May 2024, 03:39

The CreateWindowInBand function does not affect windows of other processes, but creates its own window. This class is not registered in the AHK process, hence the error message. Of course, you can register it (RegisterClass), but the created window will have no relation to Notepad.exe windows.

Ralf_Reddings200244
Posts: 110
Joined: 11 Mar 2023, 14:16

Re: Always showing a window above standard 'on top' windows

Post by Ralf_Reddings200244 » 25 May 2024, 10:19

Aah so this is cannot be used for general windows like `alwaysOnTop`, now I understand why malcev was using a gui window.

Thank you for the expalanations teadrinker, very kind of you. I will still keep this in my back pocket, looks to be usefull for GUIs too.

Post Reply

Return to “Ask for Help (v1)”