Attach window between desktop icons and background? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
theimmersion
Posts: 181
Joined: 09 Jul 2016, 08:34
Location: Serbia

Attach window between desktop icons and background?

17 Mar 2018, 10:21

Is it possible to translate this code into AHK code?
https://www.codeproject.com/articles/85 ... in-windows
I just want a nice gui / gadget made in AHK code to be on desktop behind icons.
Ive tried some DllCall stuff but got nowhere. -.-#
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Attach window between desktop icons and background?  Topic is solved

17 Mar 2018, 11:57

AHKv1 (not tested):

Code: Select all

/*
    Source: https://www.codeproject.com/articles/856020/draw-behind-desktop-icons-in-windows
*/


; Obtain Program Manager Handle
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms633499(v=vs.85).aspx
Progman := DllCall("User32.dll\FindWindowW", "Str", "Progman", "UPtr", 0, "Ptr")

; Send Message to Program Manager
DllCall("User32.dll\SendMessageW", "Ptr", Progman, "UInt", 0x052C, "Ptr", 0, "Ptr", 0)

; Obtain Handle to Newly Created Window
WinGet List, List, ahk_class WorkerW
Loop % List
{
    If (Found)
    {
        WorkerW := List%A_Index%
        Break
    }
    If (DllCall("User32.dll\FindWindowExW", "Ptr", List%A_Index%, "Ptr", 0, "Str", "SHELLDLL_DefView", "UPtr", 0, "Ptr"))
        Found := TRUE
}

; Put a Windows Form behind desktop icons
Gui, 1:New, +HWNDHwnd
DllCall("User32.dll\SetParent", "Ptr", Hwnd, "Ptr", WorkerW, "Ptr")
Gui, 1:Show, w500 h350
WinWaitClose % "ahk_id" . Hwnd
ExitApp
AHKv2:

Code: Select all

/*
    Source: https://www.codeproject.com/articles/856020/draw-behind-desktop-icons-in-windows
*/


; Obtain Program Manager Handle
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms633499(v=vs.85).aspx
Progman := DllCall('User32.dll\FindWindowW', 'Str', 'Progman', 'UPtr', 0, 'Ptr')

; Send Message to Program Manager
DllCall('User32.dll\SendMessageW', 'Ptr', Progman, 'UInt', 0x052C, 'Ptr', 0, 'Ptr', 0)

; Obtain Handle to Newly Created Window
For Each, WindowId in WinGetList('ahk_class WorkerW')
{
    If (Found)
    {
        WorkerW := WindowId
        Break
    }
    If (DllCall('User32.dll\FindWindowExW', 'Ptr', WindowId, 'Ptr', 0, 'Str', 'SHELLDLL_DefView', 'UPtr', 0, 'Ptr'))
        Found := TRUE
}

; Put a Windows Form behind desktop icons
Gui := GuiCreate()
DllCall('User32.dll\SetParent', 'Ptr', Gui.Hwnd, 'Ptr', WorkerW, 'Ptr')
Gui.Show('w500 h350')
WinWaitClose('ahk_id' . Gui.Hwnd)
ExitApp
User avatar
theimmersion
Posts: 181
Joined: 09 Jul 2016, 08:34
Location: Serbia

Re: Attach window between desktop icons and background?

17 Mar 2018, 12:22

Thanks for speedy reply. Well, i didnt try the V2 but the V1 is not working tho. It is not being attached.
The WorkerW variable in:

Code: Select all

Loop (List)
{
    If (Found)
    {
        WorkerW := List%A_Index%
        Break
    }
    If (DllCall("User32.dll\FindWindowExW", "Ptr", List%A_Index%, "Ptr", 0, "Str", "SHELLDLL_DefView", "UPtr", 0, "Ptr"))
        Found := TRUE
}
msgbox %WorkerW% ; <- i put there to check resulting find.
returns empty.
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: Attach window between desktop icons and background?

17 Mar 2018, 12:28

Sorry, try now. I have changed Loop (List) --> Loop % List
User avatar
theimmersion
Posts: 181
Joined: 09 Jul 2016, 08:34
Location: Serbia

Re: Attach window between desktop icons and background?

17 Mar 2018, 12:31

Holly ****! Finally! Thank you!
Bross9132
Posts: 14
Joined: 08 Feb 2018, 09:46

Re: Attach window between desktop icons and background?

25 Mar 2018, 19:20

I am trying to send it to monitor 2 and go behind icons but it doesn't stay on that monitor. Why doesn't this work:

Code: Select all

SysGet, MonPrimary, MonitorPrimary
SysGet, Mon1, Monitor, 1
SysGet, Mon2, Monitor, 2
SysGet, Mon3, Monitor, 3


; Obtain Program Manager Handle
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms633499(v=vs.85).aspx
Progman := DllCall("User32.dll\FindWindowW", "Str", "Progman", "UPtr", 0, "Ptr")

; Send Message to Program Manager
DllCall("User32.dll\SendMessageW", "Ptr", Progman, "UInt", 0x052C, "Ptr", 0, "Ptr", 0)

; Obtain Handle to Newly Created Window
WinGet List, List, ahk_class WorkerW
Loop % List
{
    If (Found)
    {
        WorkerW := List%A_Index%
        Break
    }
    If (DllCall("User32.dll\FindWindowExW", "Ptr", List%A_Index%, "Ptr", 0, "Str", "SHELLDLL_DefView", "UPtr", 0, "Ptr"))
        Found := TRUE
}

; Put a Windows Form behind desktop icons
Gui, 1:New, +HWNDHwnd
WinMove, GuiVid,, %Mon2Left%, %Mon2Top%
Gui, 1:Show, w500 h350
sleep, 3000
DllCall("User32.dll\SetParent", "Ptr", Hwnd, "Ptr", WorkerW, "Ptr")
WinWaitClose % "ahk_id" . Hwnd
ExitApp
User avatar
theimmersion
Posts: 181
Joined: 09 Jul 2016, 08:34
Location: Serbia

Re: Attach window between desktop icons and background?

26 Mar 2018, 07:03

@Briss9132,
Sorry, i cant help You because i dont have 2 monitors to test/try. :(
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: Attach window between desktop icons and background?

27 May 2021, 12:45

Hi @Flipeador

No need for loop.
Adapted WinExist() example from @lexikos here: Always on Bottom

Code: Select all

#NoEnv
#Warn
#SingleInstance, Force

If WinExist("ahk_class Progman", "FolderView") ; Progman in charge
   SendMessage, 0x052C                         ; Spawn WorkerW

hWorkerW   := WinExist("ahk_class WorkerW", "FolderView")
; Next WorkerW is Wallpaper
hWallpaper := DllCall("User32.dll\FindWindowEx", "Ptr",0, "Ptr",hWorkerW, "Str","WorkerW", "Ptr",0, "Ptr")

Gui, New, -Caption +Border +HwndHwnd
Gui, Margin, 0, 0
Gui, Add, Picture, w256 h256 Icon1, %A_AhkPath%
Gui, Show, Hide
DllCall("User32.dll\SetParent", "Ptr",Hwnd, "Ptr",hWallpaper)
Gui, Show

ExitApp
dummyvoid
Posts: 1
Joined: 13 Jun 2021, 00:47

Re: Attach window between desktop icons and background?

13 Jun 2021, 01:05

Hello. Did you test this program on Windows 10?
I am using Windows 10, but this program doesn't work on my system.
The window remains on desktop icons.
SKAN wrote:
27 May 2021, 12:45
Hi @Flipeador

No need for loop.
Adapted WinExist() example from @lexikos here: Always on Bottom

Code: Select all

#NoEnv
#Warn
#SingleInstance, Force

If WinExist("ahk_class Progman", "FolderView") ; Progman in charge
   SendMessage, 0x052C                         ; Spawn WorkerW

hWorkerW   := WinExist("ahk_class WorkerW", "FolderView")
; Next WorkerW is Wallpaper
hWallpaper := DllCall("User32.dll\FindWindowEx", "Ptr",0, "Ptr",hWorkerW, "Str","WorkerW", "Ptr",0, "Ptr")

Gui, New, -Caption +Border +HwndHwnd
Gui, Margin, 0, 0
Gui, Add, Picture, w256 h256 Icon1, %A_AhkPath%
Gui, Show, Hide
DllCall("User32.dll\SetParent", "Ptr",Hwnd, "Ptr",hWallpaper)
Gui, Show

ExitApp
bluesky
Posts: 11
Joined: 24 Dec 2020, 20:15

Re: Attach window between desktop icons and background?

18 Mar 2024, 01:38

how to compatible all windows version 7 to 11?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Bing [Bot], CrowexBR, mcd, rubeusmalfoy, ShatterCoder, spellegrnio1 and 85 guests