Black desktop background issue on Win 10 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

Black desktop background issue on Win 10

21 Oct 2017, 14:17

I created a script that adds transparency to desktop icons but the problem is as follows:
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
User avatar
theimmersion
Posts: 181
Joined: 09 Jul 2016, 08:34
Location: Serbia

Re: Black desktop background issue on Win 10  Topic is solved

29 Oct 2017, 08:37

In case someone ever needs something like this.
I figured it out and its rather tied up in a knot but it works.
To successfully apply trans to icons what ever active handle it may be and avoid black background, you must do this:

Code: Select all

#SingleInstance, Force

F1::
	ToggleF1:=!ToggleF1

	ControlGet, hwndProgman, Hwnd,, SysListView321, ahk_class Progman
	
	; Reset trans.
	if hwndProgman=
	{
		if !DoOnce
		{
			DoOnce=1
			WinSet,Trans,OFF, ahk_id %hwndProgman%
			WinSet,Trans,OFF, ahk_class Progman
			ControlGet, hwndWorkerW, Hwnd,, SysListView321, ahk_class WorkerW
			WinSet,Trans,255, ahk_id %hwndWorkerW%
			WinSet,Trans,OFF, ahk_id %hwndWorkerW%
			WinSet,Trans,OFF, ahk_class WorkerW
			Sleep, 3000
			WinSet,Trans,OFF, ahk_id %hwndProgman%
			WinSet,Trans,OFF, ahk_class Progman
			ControlGet, hwndWorkerW, Hwnd,, SysListView321, ahk_class WorkerW
			WinSet,Trans,255, ahk_id %hwndWorkerW%
			WinSet,Trans,OFF, ahk_id %hwndWorkerW%
			WinSet,Trans,OFF, ahk_class WorkerW
		}
	}
	else if (hwndProgman!="" and DoOnce=1)
		DoOnce=0
	
	; Toggle See through icons.
	if ToggleF1
	{
		if hwndProgman=
			WinSet, Trans, 20, ahk_class WorkerW
		else
			WinSet, Trans, 20, ahk_id %hwndProgman%
	}
	else
	{
		if hwndProgman=
			WinSet, Trans, OFF, ahk_class WorkerW
		else
			WinSet, Trans, OFF, ahk_id %hwndProgman%
	}
Return
Essentially im doing a check and all out trans reset on all desktop handles if progman is empty.
For some reason doing a trans off on all handles once doesnt work so it does it twice in a row with a delay between them.
Dont know why or how but it works. xD

Tho, i placed the reset trans into a auto-execute but this will work just fine.
Hope it helps!
Skrell
Posts: 302
Joined: 23 Jan 2014, 12:05

Re: Black desktop background issue on Win 10

18 Mar 2024, 10:36

theimmersion wrote:
29 Oct 2017, 08:37
In case someone ever needs something like this.
I figured it out and its rather tied up in a knot but it works.
To successfully apply trans to icons what ever active handle it may be and avoid black background, you must do this:

Code: Select all

#SingleInstance, Force

F1::
	ToggleF1:=!ToggleF1

	ControlGet, hwndProgman, Hwnd,, SysListView321, ahk_class Progman
	
	; Reset trans.
	if hwndProgman=
	{
		if !DoOnce
		{
			DoOnce=1
			WinSet,Trans,OFF, ahk_id %hwndProgman%
			WinSet,Trans,OFF, ahk_class Progman
			ControlGet, hwndWorkerW, Hwnd,, SysListView321, ahk_class WorkerW
			WinSet,Trans,255, ahk_id %hwndWorkerW%
			WinSet,Trans,OFF, ahk_id %hwndWorkerW%
			WinSet,Trans,OFF, ahk_class WorkerW
			Sleep, 3000
			WinSet,Trans,OFF, ahk_id %hwndProgman%
			WinSet,Trans,OFF, ahk_class Progman
			ControlGet, hwndWorkerW, Hwnd,, SysListView321, ahk_class WorkerW
			WinSet,Trans,255, ahk_id %hwndWorkerW%
			WinSet,Trans,OFF, ahk_id %hwndWorkerW%
			WinSet,Trans,OFF, ahk_class WorkerW
		}
	}
	else if (hwndProgman!="" and DoOnce=1)
		DoOnce=0
	
	; Toggle See through icons.
	if ToggleF1
	{
		if hwndProgman=
			WinSet, Trans, 20, ahk_class WorkerW
		else
			WinSet, Trans, 20, ahk_id %hwndProgman%
	}
	else
	{
		if hwndProgman=
			WinSet, Trans, OFF, ahk_class WorkerW
		else
			WinSet, Trans, OFF, ahk_id %hwndProgman%
	}
Return
Essentially im doing a check and all out trans reset on all desktop handles if progman is empty.
For some reason doing a trans off on all handles once doesnt work so it does it twice in a row with a delay between them.
Dont know why or how but it works. xD

Tho, i placed the reset trans into a auto-execute but this will work just fine.
Hope it helps!
I would kiss you if I could!!! This issue has been driving me CRAZY!!!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: arrondark, Google [Bot], mikeyww and 266 guests