Change Taskbar Color No Longer Works

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ezhdehaa
Posts: 14
Joined: 04 Mar 2022, 11:23

Change Taskbar Color No Longer Works

Post by ezhdehaa » 27 Mar 2024, 10:53

I have two autohotkey scripts. One changes the language to English and makes my taskbar black when I press Ctrl+1. The other changes the language to Persian and makes my taskbar red when I press Ctrl+2.

While the languages do change, the colors do not. I think this may be due to a Windows 11 update a few months ago. I just have not bothered looking into it until now. I will post the code for the English-Farsi .ahk below. Does anyone know why the taskbar color doesnt change anymore?

Code: Select all

 ; #Include d:\utils\TaskBar_SetAttr.ahk
^2::
SetDefaultKeyboard(0x0429)
SetDefaultKeyboard(LocaleID){
Global
SPI_SETDEFAULTINPUTLANG := 0x005A
SPIF_SENDWININICHANGE := 2
Lan := DllCall("LoadKeyboardLayout", "Str", Format("{:08x}", LocaleID), "Int", 0)
VarSetCapacity(Lan%LocaleID%, 4, 0)
NumPut(LocaleID, Lan%LocaleID%)
DllCall("SystemParametersInfo", "UInt", SPI_SETDEFAULTINPUTLANG, "UInt", 0, "UPtr", &Lan%LocaleID%, "UInt", SPIF_SENDWININICHANGE)
WinGet, windows, List
Loop %windows% {
PostMessage 0x50, 0, %Lan%, , % "ahk_id " windows%A_Index%
}
}
return
/*
TaskBar_SetAttr(option, color)
option -> 0 = off
1 = gradient (+color)
2 = transparent (+color)
3 = blur
color -> ABGR (alpha | blue | green | red) 0xffd7a78f
*/
TaskBar_SetAttr(accent_state := 0, gradient_color := "0x01000000")
{
static init, hTrayWnd, ver := DllCall("GetVersion") & 0xff < 10
static pad := A_PtrSize = 8 ? 4 : 0, WCA_ACCENT_POLICY := 19
if !(init) {
if (ver)
throw Exception("Minimum support client: Windows 10", -1)
if !(hTrayWnd := DllCall("user32\FindWindow", "str", "Shell_SecondaryTrayWnd", "ptr", 0, "ptr"))
throw Exception("Failed to get the handle", -1)
init := 1
}
accent_size := VarSetCapacity(ACCENT_POLICY, 16, 0)
NumPut((accent_state > 0 && accent_state < 4) ? accent_state : 0, ACCENT_POLICY, 0, "int")
if (accent_state >= 1) && (accent_state <= 2) && (RegExMatch(gradient_color, "0x[[:xdigit:]]{8}"))
NumPut(gradient_color, ACCENT_POLICY, 8, "int")
VarSetCapacity(WINCOMPATTRDATA, 4 + pad + A_PtrSize + 4 + pad, 0)
&& NumPut(WCA_ACCENT_POLICY, WINCOMPATTRDATA, 0, "int")
&& NumPut(&ACCENT_POLICY, WINCOMPATTRDATA, 4 + pad, "ptr")
&& NumPut(accent_size, WINCOMPATTRDATA, 4 + pad + A_PtrSize, "uint")
if !(DllCall("user32\SetWindowCompositionAttribute", "ptr", hTrayWnd, "ptr", &WINCOMPATTRDATA))
throw Exception("Failed to set transparency / blur", -1)
return true
}

Return to “Ask for Help (v1)”