Always On Bottom

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
masimpson
Posts: 2
Joined: 21 Aug 2020, 20:12

Always On Bottom

Post by masimpson » 25 Aug 2020, 20:48

I know this has been asked a bunch of times, but I've been unable to find a working method for keeping a window pinned to the desktop.

The method I keep seeing prescribed is to make the window a child of the desktop using SetParent. For instance:

Code: Select all

DllCall( "SetParent", UInt, WinExist( "Untitled - Notepad" ) , UInt, WinExist( "Program Manager" ) )
However, on Windows 10 this doesn't seem to function properly as the window in question simply disappears.

I'm not terribly familiar with AHK or the Windows GUI structure. And while I get the idea, I feel that I'm missing a step.

Is there something about the hierarchy which has changed in Windows 10 that would cause this issue?

Any help is appreciated.

P.S. I was able to mimic the desired effect using Actual Window Manager, but I do not want to abandon the simplicity of AHK for this purpose.

Nor do I want to take on the overhead of ActualTools software.

trust_me
Posts: 98
Joined: 29 Jul 2017, 10:46

Re: Always On Bottom

Post by trust_me » 26 Aug 2020, 12:20

https://www.autohotkey.com/docs/commands/WinSet.htm

I would use a " SetTimer " and WinSet , Bottom . I use PotPlayer to have a video as wallpaper a value of 3000 ms keeps it happily down .

A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Always On Bottom

Post by A_AhkUser » 26 Aug 2020, 15:11

Hi masimpson,

UInt should be Ptr in newer version of ahk for HWND (such as those returned by WinExist). Also try identify notepad by its class instead:

Code: Select all

DllCall("User32.dll\SetParent", "Ptr", WinExist("ahk_class Notepad"), "Ptr", WinExist("Program Manager"))

Hope this helps

A_AhkUser
my scripts

masimpson
Posts: 2
Joined: 21 Aug 2020, 20:12

Re: Always On Bottom

Post by masimpson » 26 Aug 2020, 19:01

trust_me wrote:
26 Aug 2020, 12:20
https://www.autohotkey.com/docs/commands/WinSet.htm

I would use a " SetTimer " and WinSet , Bottom . I use PotPlayer to have a video as wallpaper a value of 3000 ms keeps it happily down .
I need to interact with the window.
A_AhkUser wrote:
26 Aug 2020, 15:11
Hi masimpson,

UInt should be Ptr in newer version of ahk for HWND (such as those returned by WinExist). Also try identify notepad by its class instead:

Code: Select all

DllCall("User32.dll\SetParent", "Ptr", WinExist("ahk_class Notepad"), "Ptr", WinExist("Program Manager"))

Hope this helps

A_AhkUser
While this may be a more up-to-date usage of the method I specified, it results in the same effect: the window simply disappears.

Thanks for the replies, though.

lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: Always On Bottom

Post by lexikos » 26 May 2021, 04:03

( For anyone who comes across this topic while searching for "always on bottom": )

The window which actually contains the desktop icons on Windows 10 is WinExist("ahk_class WorkerW", "FolderView"), so just use that instead of WinExist("Program Manager"). It may be WorkerW on some older versions as well.

Code: Select all

DllCall("SetParent", "uint", WinExist("Untitled - Notepad"), "uint", WinExist("ahk_class WorkerW", "FolderView"))
It's irrelevant whether you use uint or ptr when passing HWND values.
kernel32 and user32 handles are only 32-bit significant in both 32-bit and 64-bit processes
Source: 32-bit and 64-bit Interoperability - Win32 apps | Microsoft Docs
(Actually wasn't the quote I was looking for, but it'll do.)

User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: Always On Bottom

Post by SKAN » 26 May 2021, 17:21

Hi @lexikos
The window which actually contains the desktop icons on Windows 10 is WinExist("ahk_class WorkerW", "FolderView")
That's usually the case for people who opt for slideshow background.
The listview that hosts Desktop icons is a child of ahk_class SHELLDLL_DefView
The owner of SHELLDLL_DefView can dynamically change from ahk_class Progman to ahk_class WorkerW

I never use slideshow background. So when windows boot, ahk_class Progman has been the parent of ahk_class SHELLDLL_DefView
for me in Window 7, 8.1 and 10.
The ownership/parentship will be transferred to ahk_class WorkerW if I use WIN+TAB in Win 10. which I usually don't. (WIN+TAB also does this in Win 7, I think).
SetParent() has side effects, for example the window changes theme to Win 7 and also become slightly transparent.

In my OSDTIP_Dektop(), I don't use SetParent().
I just set ahk_class SHELLDLL_DefView as the owner of my Progress UI, so any change to ahk_class SHELLDLL_DefView's owner/parent wouldn't affect my UI.
I think the rule for Show desktop is something like this.
When Win+D is pressed, all windows except the parent of ahk_class SHELLDLL_DefView will get minimized.
and this is what happening to OP:
Progman wasn't the parent of ahk_class SHELLDLL_DefView and was set as the parent of a window.
WIn+D was pressed to see the desktop and both Progman and its child Window got minimized.
 

Code: Select all

WinExist("ahk_class WorkerW", "FolderView")
That's beautiful. Simple, yet I didn't think of it,
It wouldn't be affected by DetectHiddenWindows, on like my DesktopIcons() does.
 
It's irrelevant whether you use uint or ptr when passing HWND values.
I didn't know. Thanks. :)

I guess nobody would look inside my OSDTIP() topic to find this.
I will post a separate function and tag you.

lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: Always On Bottom

Post by lexikos » 26 May 2021, 22:25

Interesting. I don't use slideshow background, but I may have pressed win-tab at some point since my computer booted (I don't intentionally use it).

User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: Always On Bottom

Post by SKAN » 27 May 2021, 12:47

lexikos wrote:
26 May 2021, 22:25
Interesting. I don't use slideshow background, but I may have pressed win-tab at some point since my computer booted (I don't intentionally use it).
I found WorkerW can be spawned without WIN+TAB

Code: Select all

If WinExist("ahk_class Progman", "FolderView") ; Progman in charge
   SendMessage, 0x052C                         ; Spawn WorkerW
https://www.autohotkey.com/boards/viewtopic.php?p=402115#p402115

Post Reply

Return to “Ask for Help (v1)”