Attach window between desktop icons and background? Topic is solved
- theimmersion
- Posts: 181
- Joined: 09 Jul 2016, 08:34
- Location: Serbia
Attach window between desktop icons and background?
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. #
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. #
Re: Attach window between desktop icons and background? Topic is solved
AHKv1 (not tested):
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
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
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
- theimmersion
- Posts: 181
- Joined: 09 Jul 2016, 08:34
- Location: Serbia
Re: Attach window between desktop icons and background?
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:
returns empty.
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.
Re: Attach window between desktop icons and background?
Sorry, try now. I have changed Loop (List) --> Loop % List
- theimmersion
- Posts: 181
- Joined: 09 Jul 2016, 08:34
- Location: Serbia
Re: Attach window between desktop icons and background?
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
- theimmersion
- Posts: 181
- Joined: 09 Jul 2016, 08:34
- Location: Serbia
Re: Attach window between desktop icons and background?
@Briss9132,
Sorry, i cant help You because i dont have 2 monitors to test/try.
Sorry, i cant help You because i dont have 2 monitors to test/try.
Re: Attach window between desktop icons and background?
Hi @Flipeador
No need for loop.
Adapted WinExist() example from @lexikos here: Always on Bottom
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
Re: Attach window between desktop icons and background?
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.
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:45Hi @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
Re: Attach window between desktop icons and background?
how to compatible all windows version 7 to 11?