When rebooting OS or restarting explorer.exe the desktop class for icons starts off as Progman but some apps as well as going into TaskView changes the class to WorkerW.
The issue here is when modifying transparency to Progman handle and than changing the handle to WorkerW, modifying the transparency after will result in a some kind of black overlay above wallpaper and behind icons. I made a test script as a demo of its behavior. This is also potentially true for Win 7. If the handle never changed, there would be no issue but this is supposed to be a hide show icons script so it supposed to work with both handles and this is a rather big bug. Any way to overcome this issue? I believe Win 7 has the same behavior, only i dont know how to force win 7 to WorkerW since it doesnt have TaksView as far as i know. I googled the hell out it to find a solution but had no luck. The only solution i can think of is to check for WorkerW and ignore Progman. That has a side effect of not being able to hide the icons on Win 7 and for users not having any apps that make the handle switch to WorkerW as well as people not using TaskView. Making the user go into TaksView at boot or doing a send Win+Tab combo is just an ugly hack and would only work on win 10. xD Any ideas?
This code is meant for Win 10 since it has TaksView to force to WorkerW with a Gui to troubleshoot.
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance, Force
SetTimer, GuiUpdate, 100
Gui,Margin, 10,0
Gui,Add,Text, xm0 ym10 w200 h20 vTick, %Tick%
Gui,Add,Text, w200 h20 vHandle, Handle:
ControlGet, hwnd, Hwnd,, SysListView321, ahk_class Progman
if hwnd=
Gui,Add,Text, w200 h150 vNotes, Note:`nThis demo wont work starting with WorkerW class.`n`n`n`nTo change to Progman class, restart Explorer.exe.
else
Gui,Add,Text, w200 h150 vNotes, Note:
Gui,Add,Text, w200 h20,
Gui,Add,Text, w200 h20, Set Transparency:
Gui,Add,Button, w200 h20 gProgman20, 20
Gui,Add,Button, w200 h20 gProgman255, 255
Gui,Add,Button, w200 h20 gProgmanOFF, OFF
Gui,Add,Text, w200 h20, Show/Hide class:
Gui,Add,Button, w200 h20 gHide, Hide
Gui,Add,Button, w200 h20 gShow, Show
Gui,Add,Text, w200 h20,
Gui,Add,Button, w200 h20 gRestartExplorer, Restart Explorer.exe
Gui,Add,Text, w200 h20,
Gui,Add,Text, w200 h20,
Gui,Add,Button, w200 h20 gRestartScript, Restart Script
Gui,Add,Text, xn w200 h20,
Gui, Show, x0 y0 w220
Return
GuiUpdate:
if Tick=•••••••••••••••••••••••••••••••••
Tick=
else
Tick.="•"
ControlGet, hwnd, Hwnd,, SysListView321, ahk_class Progman
if hwnd=
{
ControlGet, hwnd, Hwnd,, SysListView321, ahk_class WorkerW
class:="WorkerW"
}
else
class:="Progman"
GuiControl,, Tick, %Tick%
GuiControl,, Handle, Class: %class% | Handle: %hwnd%
Return
Progman20:
Setting:="Transparency set to 20"
WinSet, Trans, 20, ahk_id %hwnd%
if (class="Progman")
GuiControl,, Note, Note:`nChanging the handle now`n and modifying transparency`nwill affect desktop background.`n`nTo switch handle, go in and out of TaskView (WinKey+TabKey) and refresh desktop.`n`nTo revert to Progman class, restart Explorer.exe.
else
GuiControl,, Note,
Return
Progman255:
Setting:="Transparency set to 255"
WinSet, Trans, 255, ahk_id %hwnd%
if (class="Progman")
GuiControl,, Note, Note:`nChanging the handle now`n and modifying transparency`nwill affect desktop background.`n`nTo switch handle, go in and out of TaskView (WinKey+TabKey) and refresh desktop.`n`nTo revert to Progman class, restart Explorer.exe.
else
GuiControl,, Note,
Return
ProgmanOFF:
Setting:="Transparency set to OFF"
WinSet, Trans, OFF, ahk_id %hwnd%
if (class="Progman")
GuiControl,, Note, Note:`nChanging the handle now`n and modifying transparency`nwill affect desktop background.`n`nTo switch handle, go in and out of TaskView (WinKey+TabKey) and refresh desktop.`n`nTo revert to Progman class, restart Explorer.exe.
else
GuiControl,, Note,
Return
Hide:
WinHide, ahk_id %hwnd%
Return
Show:
WinShow, ahk_id %hwnd%
Return
RestartScript:
Reload
Return
RestartExplorer:
;4096+4 (AlwaysOnTop+MsgBoxType)
MsgBox, 4100, %ApplicationName%, This will force restart Explorer.exe and will close all open explorer and explorer associated windows.`nContinue?
IfMsgBox, Yes
{
Gui, Destroy
Gui,Margin, 10,0
Gui,Add,Text, w200 h20 vTick, %Tick%
Gui,Add,Text, w200 h150 vNotes, RESTARTING
Gui, Show, x0 y0 w400 h400
run, taskkill /f /im explorer.exe
sleep, 2000
run, explorer.exe
sleep, 2000
Reload
}
Return
GuiClose:
ExitApp