It is currently March 29th, 2024, 1:36 am

Windows 10 Taskbar/Accent Color Matching

Tips and Tricks from the Rainmeter Community
DollarD
Posts: 16
Joined: March 2nd, 2013, 5:56 pm

Windows 10 Taskbar/Accent Color Matching

Post by DollarD »

This is an easy way of getting the color of the Win10 taskbar if you've set it to pick one from the background.

Well, you have two options. Either you use the RunCommand.dll plugin, or you do it the long way round with a .vbs script and the quote plugin. The RunCommand option seems more... elegant, and has less disk IO.

Code: Select all


[Rainmeter]
Update=1000

[MeasureColorTrigger]
Measure=String
OnUpdateAction=[!CommandMeasure MeasurePaletteRegistry Run]
DynamicVariables=1
UpdateDivider=-1

[MeasurePaletteRegistry]
Measure=Plugin
Plugin=Plugin\RunCommand.dll
Parameter=C:\Windows\System32\reg.exe query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent /v AccentPalette
OutputType=ANSI
FinishAction=[!UpdateMeasure "MeasureSplitPaletteBG"]
DynamicVariables=1
UpdateDivider=-1

[MeasureSplitPaletteBG]
Measure=String
String=[MeasurePaletteRegistry]
DynamicVariables=1
RegExpSubstitute=1
Substitute="(?siU).*REG_BINARY\s*([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2}).*":"\21\22\23"
-- Select a palette entry from
-- "\1\2\3\4 \5\6\7\8 \9\10\11\12 \13\14\15\16 \17\18\19\20 \21\22\23\24 \25\26\27\28 \29\30\31\32"
UpdateDivider=-1

And you'll have the color in [MeasureSplitPaletteBG]. You can source other colors in the same palette by using [MeasureSplitPaletteBG]'s regex as I suggested in the comments.

To see how you do it the hard way, with a .vbs script, see here: http://rainmeter.net/forum/viewtopic.php?f=99&t=21223

If you have a background changer, using SysColor.dll to trigger the extract is still advised, instead of triggering via rainmeter command line from the changer. That way the extract is done after changes are committed to registry. Seems its too quick otherwise. Like so, then:

Code: Select all


[MeasureColorTrigger]
Measure=Plugin
Plugin=Plugin\SysColor.dll
ColorType=Aero 
Hex=1
DisplayType=ALL
OnChangeAction=[!CommandMeasure MeasurePaletteRegistry Run]
DynamicVariables=1

Much less convoluted, no?

RunCommand plugin: https://github.com/brianferguson/RunCommand.dll
SysColor plugin: https://github.com/brianferguson/SysColor.dll

Dedicated to Brian Ferguson. Making my life better, one plugin at a time.
User avatar
Brian
Developer
Posts: 2674
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Windows 10 Taskbar/Accent Color Matching

Post by Brian »

8-)

-Brian
ingoldxc1090
Posts: 2
Joined: September 27th, 2015, 9:08 pm

Re: Windows 10 Taskbar/Accent Color Matching

Post by ingoldxc1090 »

I'm fairly new to this but I've successfully set it up using a combination of the RunCommand.dll and the SysColor.dll plugins I have the SysColor plugin set to activate the RunCommand plugin because I have a changing background color. I did this, because it seemed to me that the colors given by the SysColor plugin were not always accurate. I did, however find that the colors that the RunCommand plugin outputs are accurate, but they are solid and I would like them to have transparency like the accent color on windows 10. So my question is, is there any way to edit the code that you have posted so that I can specify my own alpha value to remain constant?
DollarD
Posts: 16
Joined: March 2nd, 2013, 5:56 pm

Re: Windows 10 Taskbar/Accent Color Matching

Post by DollarD »

Hi ingoldxc1090,

Yeah, the SysColor inaccuracy is why I developed this little workaround. In the case of transparency, I use gradients to blend between alpha (transparency) levels, but in your case, its even simpler. It outputs as a Hex color RGB, so you just concatenate to create RGBA, like so:

In your Variables section:

Code: Select all

[Variables]
ConstAlpha=AF
and then in the meter:

Code: Select all

[ExampleMeter]
Meter=Image
SolidColor=[MeasureSplitPaletteBG]#ConstAlpha#
And voila. Values range from 00 to FF.

If you'd like to fetch the transparency as well, you just need to change the regex. You'll note I mentioned:

Code: Select all

-- Select a palette entry from
-- "\1\2\3\4 \5\6\7\8 \9\10\11\12 \13\14\15\16 \17\18\19\20 \21\22\23\24 \25\26\27\28 \29\30\31\32"
But then at the end of the regex, I end with

Code: Select all

:"\21\22\23"
If you change that to

Code: Select all

:"\21\22\23\24"
It fetches the transparency as well, but that prevents you from setting the alpha yourself. Something for you to play around with, I guess. :)
User avatar
2bndy5
Posts: 20
Joined: February 25th, 2015, 2:38 am

Re: Windows 10 Taskbar/Accent Color Matching

Post by 2bndy5 »

Awesome work! Thought I'd share some of what I've learned using this reg key.
The pattern is as you said (RR BB GG), but the forth byte is consistently 00 for me. (maybe they changed the algorithm in the November update; I've read that they're working on implementing a dark theme like the one in Microsoft edge) Not sure how that 00 equates to actual Alpha value as it makes the color completely transparent. So I used the 00 as a delimiter in my regex substitution.

Code: Select all

[MeasureSplitPalette]
Measure=String
String=[MeasurePaletteRegistry]
DynamicVariables=1
updateDivider=-1
group=ExtractColors
RegExpSubstitute=1
Substitute="(?siU).*REG_BINARY\s*([[:xdigit:]]{6})00([[:xdigit:]]{6})00([[:xdigit:]]{6})00([[:xdigit:]]{6})00([[:xdigit:]]{6})00([[:xdigit:]]{6})00([[:xdigit:]]{6})00([[:xdigit:]]{6})00":"\7#Alpha#"
;;PATTERN = RRBBGG00 {8}
;; Select a palette entry from
;; "\1\2\3\4\5\6\7\8"
;;\3 = Highlight active menu Selection
;;\4 = Active Window Color
;;\5 = brighter BG
;;\6 = darker BG
;;\7 = much darker BG
Notice I replaced the quantifier 2 with 6 since there's no need to capture individual color segments unless you're going to manipulate them individually. Also notice I've added my alpha variable in the resulting substitute because using solidColor=[MeasureSplitPalette]#Alpha# wasn't working (not sure why). The comments are just there to help me know which color will look like.