AttachToDesktop() - Attach a window in front of the wallpaper and behind the desktop icons.

Post your working scripts, libraries and tools for AHK v1.1 and older
tuzi
Posts: 223
Joined: 27 Apr 2016, 23:40

AttachToDesktop() - Attach a window in front of the wallpaper and behind the desktop icons.

14 Oct 2021, 08:14

How to use:

AttachToDesktop(HWND)


Function:

Code: Select all

; Attach the target window in front of the wallpaper and behind the desktop icons.
; Obviously, you can attach a normal window, a video player, a browser, etc.
; 使用 AttachToDesktop(目标窗口句柄) 可以将目标窗口贴在桌面上 图标下
; 显然 你可以贴普通窗口 贴视频播放器 贴浏览器等等
AttachToDesktop(hWindow)
{
  SendMessage, 0x052C, 0, 0, , % "ahk_id " WinExist("ahk_class Progman")
  WinGet, Matched, List, ahk_class WorkerW
  loop, % Matched
  {
    ; 有 SHELLDLL_DefView 的窗口是存图标的,没有的是存壁纸的
    if (!DllCall("FindWindowEx", "Ptr", Matched%A_Index%, "Ptr", 0, "Str", "SHELLDLL_DefView", "UPtr", 0, "Ptr"))
      hWorkerW := Matched%A_Index%
  }
  DllCall("SetParent", "Ptr", hWindow, "Ptr", hWorkerW, "Ptr")
}

Demo1 - GDIP Dynamic Wallpaper

Image

This is a big GIF.
Image


Demo2 - Nixie Clock

Image

This is a GIF.
Image

Download
Last edited by tuzi on 20 Oct 2021, 01:41, edited 2 times in total.
viv
Posts: 219
Joined: 09 Dec 2020, 17:48

Re: AttachToDesktop() - Attach a window in front of the wallpaper and behind the desktop icons.

15 Oct 2021, 07:32

Thank you very much, I am going to use this


AHK V2 version

Code: Select all

AttachToDesktop(hWindow)
{
  SendMessage(0x052C, 0, 0, , "ahk_id " WinExist("ahk_class Progman"))
  Matched := WinGetList("ahk_class WorkerW")
  loop Matched.length
  {
    if !DllCall("FindWindowEx", "Ptr", Matched[A_Index], "Ptr", 0, "Str", "SHELLDLL_DefView", "UPtr", 0, "Ptr")
      hWorkerW := Matched[A_Index]
  }
  DllCall("SetParent", "Ptr", hWindow, "Ptr", hWorkerW, "Ptr")
}
bluesky
Posts: 11
Joined: 24 Dec 2020, 20:15

Re: AttachToDesktop() - Attach a window in front of the wallpaper and behind the desktop icons.

18 Mar 2024, 01:22

It seems not compitable with all windows version,low version such as win7 may use proman, but win11 use workerW?

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 161 guests