Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rainmeter plugin for making taskbar translucent. http://arkenthera.deviantart.com/art/TranslucentTaskbar-1-0-656402039
#include <Windows.h>
#include "../../API/RainmeterAPI.h"
struct ACCENTPOLICY {
int nAccentState;
int nFlags;
int nColor;
int nAnimationId;
};
struct WINCOMPATTRDATA {
int nAttribute;
PVOID pData;
ULONG ulDataSize;
};
enum AccentTypes {
ACCENT_DISABLE = 0,
ACCENT_ENABLE_GRADIENT = 1,
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
ACCENT_ENABLE_BLURBEHIND = 3
};
bool IsWindows10() {
OSVERSIONINFOA info;
ZeroMemory(&info, sizeof(OSVERSIONINFOA));
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
GetVersionExA(&info);
return info.dwMajorVersion == 10;
}
void SetBlurBehind(HWND hwnd, AccentTypes desiredType) {
if (IsWindows10()) {
const HINSTANCE hModule = LoadLibrary(TEXT("user32.dll"));
if (hModule) {
typedef BOOL(WINAPI*pSetWindowCompositionAttribute)(HWND,
WINCOMPATTRDATA*);
const pSetWindowCompositionAttribute
SetWindowCompositionAttribute =
(pSetWindowCompositionAttribute)GetProcAddress(
hModule,
"SetWindowCompositionAttribute");
// Only works on Win10
if (SetWindowCompositionAttribute) {
ACCENTPOLICY policy =
{ desiredType
,0,desiredType == (ACCENT_ENABLE_TRANSPARENTGRADIENT) ? 255 : 0,0 };
WINCOMPATTRDATA data = { 19,&policy,sizeof(ACCENTPOLICY) };
SetWindowCompositionAttribute(hwnd, &data);
}
FreeLibrary(hModule);
}
}
else {
//Nothing
}
}
HWND TaskbarHandle = FindWindow(L"Shell_TrayWnd", NULL);
HWND SecondaryTaskbar = FindWindow(L"Shell_SecondaryTrayWnd", NULL);
struct Measure
{
AccentTypes State;
Measure() : State(ACCENT_ENABLE_BLURBEHIND) {}
};
PLUGIN_EXPORT void Initialize(void** data, void* rm)
{
Measure* measure = new Measure;
*data = measure;
}
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
Measure* measure = (Measure*)data;
LPCWSTR value = RmReadString(rm, L"AccentState", L"");
if (_wcsicmp(value, L"0") == 0)
{
measure->State = ACCENT_DISABLE;
}
else if (_wcsicmp(value, L"1") == 0)
{
measure->State = ACCENT_ENABLE_GRADIENT;
}
else if (_wcsicmp(value, L"2") == 0)
{
measure->State = ACCENT_ENABLE_TRANSPARENTGRADIENT;
}
else if (_wcsicmp(value, L"3") == 0)
{
measure->State = ACCENT_ENABLE_BLURBEHIND;
}
else
{
measure->State = ACCENT_ENABLE_BLURBEHIND;
}
}
PLUGIN_EXPORT double Update(void* data)
{
Measure* measure = (Measure*)data;
SetBlurBehind(TaskbarHandle, measure->State);
SetBlurBehind(SecondaryTaskbar, measure->State);
SecondaryTaskbar = FindWindow(L"Shell_SecondaryTrayWnd", NULL);
// Just in case
int GuardCounter = 0;
while (SecondaryTaskbar = FindWindowEx(0, SecondaryTaskbar, L"Shell_SecondaryTrayWnd", L""))
{
if (GuardCounter > 8)
break;
SetBlurBehind(SecondaryTaskbar, measure->State);
GuardCounter++;
}
return 0.0;
}
PLUGIN_EXPORT void Finalize(void* data)
{
Measure* measure = (Measure*)data;
SetBlurBehind(TaskbarHandle, ACCENT_DISABLE);
SetBlurBehind(SecondaryTaskbar, ACCENT_DISABLE);
SecondaryTaskbar = FindWindow(L"Shell_SecondaryTrayWnd", NULL);
int GuardCounter = 0;
while (SecondaryTaskbar = FindWindowEx(0, SecondaryTaskbar, L"Shell_SecondaryTrayWnd", L""))
{
if (GuardCounter > 8)
break;
SetBlurBehind(SecondaryTaskbar, ACCENT_DISABLE);
GuardCounter++;
}
delete measure;
}
@KadeG

This comment has been minimized.

Copy link

@KadeG KadeG commented Feb 11, 2017

Could this be modified to add blur behind other elements?

@arkenthera

This comment has been minimized.

Copy link
Owner Author

@arkenthera arkenthera commented Feb 19, 2017

Yes, just do SetBlurBehind(HWND, ACCENT_ENABLE_BLURBEHIND)

@cnkhondo

This comment has been minimized.

Copy link

@cnkhondo cnkhondo commented Apr 15, 2017

Is there any chance you could make the action center in win10 transparent too?

@arkenthera

This comment has been minimized.

Copy link
Owner Author

@arkenthera arkenthera commented Apr 19, 2017

I briefly tried doing SetBlurBehind(....., ACCENT_ENABLE_BLURBEHIND) where .......... is the action center handle but it didnt work. If you find the correct HWND of the action center and call the method it should work. Not sure though.

@Sparqed

This comment has been minimized.

Copy link

@Sparqed Sparqed commented Dec 29, 2017

Found a bug with installing file,
I know this has nothing to do with your plugin, but im on windows 10 and its telling me it can not be used on my windows version,
a sollution from my end was to just open it in a archiver (like winrar) and just install the parts manually by creating some folders in some places.
here is a screenshot
https://i.imgur.com/piEEnjK.png
(could not post on devian art i was too lazy to register)

@rabbaniqibar2302

This comment has been minimized.

Copy link

@rabbaniqibar2302 rabbaniqibar2302 commented Jan 1, 2018

how to install it?

@himouto

This comment has been minimized.

Copy link

@himouto himouto commented Apr 3, 2018

can you make one for titlebars as well? it would be awesome

@Frai7ty

This comment has been minimized.

Copy link

@Frai7ty Frai7ty commented Nov 8, 2018

Are there any plans to (or is it possible in Rainmerter?) to revert the taskbar to it's default state when an app is maximized?

@Vaaand

This comment has been minimized.

Copy link

@Vaaand Vaaand commented Mar 31, 2019

You can adapt with "Adaptive translucent Taskbar"

@BishopLake

This comment has been minimized.

Copy link

@BishopLake BishopLake commented Apr 5, 2019

I haven't come across this kind of base windows integration in other rainmeter skins, i was wondering if you could find a way to override the default minimum size of the taskbar. The skin and plugin you have created have made my desktop a whole lot cleaner with a 100% transparent taskbar at the top of the screen. but even with small taskbar icons enabled its still too large for my tastes. thank you for this wonderful QOL add-on and thank you in advance for anything further.

@Refzlund

This comment has been minimized.

Copy link

@Refzlund Refzlund commented Feb 3, 2020

Can you make it, so in the .ini file on RainMeter, you get to choose the amount of opacity applied?
I want to darken it. Thanks in advance😁

@VAsHachiRoku

This comment has been minimized.

Copy link

@VAsHachiRoku VAsHachiRoku commented Mar 18, 2020

how to install it?

Same I'm new to this and Rainmeter seem to have a skins installation method, not a plugin method. Searched around no clue whats needed to get this to work. Please add an rm file to you're GitRepo or possible a Wiki on where the file should be placed and other files that need to be edit to make it work.

@JotaRata

This comment has been minimized.

Copy link

@JotaRata JotaRata commented Jun 6, 2020

Hello I made some adjustments to this skin, adding the feature of turn opaque or transparent whether the desktop is focused or not. I want to share it heer, but I dont know where

@Robby-Sodhi

This comment has been minimized.

Copy link

@Robby-Sodhi Robby-Sodhi commented Aug 31, 2020

is there anyway to make it only transparent on the desktop?

@hobbica98

This comment has been minimized.

Copy link

@hobbica98 hobbica98 commented Sep 23, 2020

Hey man, for the 2 screen problem that a taskbar won't update. you need to reset the secondarytaskbar var after the while.


PLUGIN_EXPORT double Update(void* data)
{
	Measure* measure = (Measure*)data;

	SetBlurBehind(TaskbarHandle, measure->State);
	SetBlurBehind(SecondaryTaskbar, measure->State);

	SecondaryTaskbar = FindWindow(L"Shell_SecondaryTrayWnd", NULL);

	// Just in case 
	int GuardCounter = 0;
	while (SecondaryTaskbar = FindWindowEx(0, SecondaryTaskbar, L"Shell_SecondaryTrayWnd", L""))
	{
		if (GuardCounter > 8)
			break;
		SetBlurBehind(SecondaryTaskbar, measure->State);
		GuardCounter++;
	}
	SecondaryTaskbar = FindWindow(L"Shell_SecondaryTrayWnd", NULL);

	return 0.0;
}

Like so

@paramsiddharth

This comment has been minimized.

Copy link

@paramsiddharth paramsiddharth commented Aug 22, 2021

Can you check out Lively? It is another Windows customization tool, and is open source. It provides all different taskbar customization features. You might want to look into its source code, though it is written in C# rather than C++.

@yuceltoluyag

This comment has been minimized.

Copy link

@yuceltoluyag yuceltoluyag commented Sep 4, 2021

i have a problem the task bar of windows still remains black pls fix

@paramsiddharth

This comment has been minimized.

Copy link

@paramsiddharth paramsiddharth commented Sep 4, 2021

i have a problem the task bar of windows still remains black pls fix

@yuceltoluyag Go to Windows Settings, turn off transparency, and turn it back on. That fixes the problem for most cases.

If it doesn't, try turning the charging on and off if a laptop. Try switching the power saver and performance modes. If none of that works, then move on to looking for more solutions on the Internet and fiddle with the registry and drivers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment