It is currently February 22nd, 2024, 5:12 pm

ColorizationColor convert to ...

Get help with creating, editing & fixing problems with skins
User avatar
AlC
Posts: 329
Joined: June 9th, 2011, 6:46 pm

ColorizationColor convert to ...

Post by AlC »

Hey Guys,

I have a little tricky problem at the moment.
I wanna get the value for ColorizationColor which is here: (regedit.exe)

HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM\ColorizationColor

With this value I wanna set an Image-Meter's Solidcolor (see code).
Problem is that Windows show the value (in regedit) as Hex and Dezimal (but DWord). And with the Registry measure I get the value as a long decimal like 3640674219 ( which is mid-dark blue). And I have no idea what I should do with the long decimal value.
And Rainmeter want for SolidColor a RGB(A) or hex value. :???:
Summarized: (Example Mid-Dark Blue)

In regedit:
hex - 0xd90047ab
dez - 3640674219

Output from the registry measure:
3640674219

Value that should be in Solidcolor:
0,71,171,Alpha
After some time searching with google I found only 1 thing that was for me usefull
-> 0xd90047ab = 0xAARRGGBB

And many code example how I can do it in C++, Python, C# or whatever ... :uhuh:

So maybe you can help me a little bit
(Hope you understand everything)

[Example Code]

Code: Select all

[Rainmeter]
Update=1000

[mWindowsBarColor]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\Microsoft\Windows\DWM 
RegValue=ColorizationColor

[String]
Meter=String
measurename=mWindowsBarColor
FontColor=255,255,255

[Background]
Meter=Image
SolidColor=VALUE
Y=20R
W=100
H=100
DynamicVariables=1
Rainmeter - You are only limited by your imagination and creativity.
User avatar
jsmorley
Developer
Posts: 22620
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ColorizationColor convert to ...

Post by jsmorley »

Here is a little Lua script you could use with your skin:

Skin:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[mWindowsBarColor]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\Microsoft\Windows\DWM
RegValue=ColorizationColor

[String]
Meter=String
measurename=mWindowsBarColor
FontColor=255,255,255

[MeasureLuaScript]
Measure=Script
ScriptFile=Test.lua
UpdateDivider=5

[Background]
Meter=Image
SolidColor=00000001
Y=20R
W=100
H=100
Lua:

Code: Select all

function Initialize()

msBarColor = SKIN:GetMeasure('mWindowsBarColor')

end

function Update()

DecColor = msBarColor:GetValue()
HexRaw = Dec2Hex(DecColor)
HexColor = string.sub(HexRaw, 3)
HexAlpha = string.sub(HexRaw, 1,2)

SKIN:Bang('!SetOption Background SolidColor '..HexColor..HexAlpha)

return HexColor..HexAlpha

end

function Dec2Hex(nValue)
	-- Convert string to number if needed
	if type(nValue) == "string" then
		nValue = String.ToNumber(nValue);
	end
	nHexVal = string.format("%X", nValue);  -- %X returns uppercase hex, %x gives lowercase letters
	-- Convert number to string
	sHexVal = nHexVal.."";
	return sHexVal;
end
What this does is take the number returned by the skin's measure (3640674219 in this case) and convert it to hex (D90047AB) which is formatted as AARRGGBB, not what Rainmeter needs. So we use string.sub to put the first two characters at the end, and we get 0047ABD9, which is that nice middle dark blue with an alpha of 217. Then the script just uses !SetOption to set the SolidColor of your background meter. Rainmeter will use either 0,71,171,217 or 0047ABD9 and it means the same thing.
User avatar
AlC
Posts: 329
Joined: June 9th, 2011, 6:46 pm

Re: ColorizationColor convert to ...

Post by AlC »

(Sorry for the delay)

Thank you so much !!!

I had the idea of cutting the hex value, too. But I didn't have the hex value :) .
And if I had the hex value, I couldn't realize it with lua. But I had the idea :D .

And with your code I could add the Transparency feature now.

Code: Select all

[mTransparency]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\Microsoft\Windows\DWM
RegValue=ColorizationOpaqueBlend
;UpdateDivider=-1

Code: Select all

function Initialize()

msBarColor = SKIN:GetMeasure('mWindowsBarColor')
msBarTrans = SKIN:GetMeasure('mTransparency')
end

function Update()

Trans = msBarTrans:GetValue()
DecColor = msBarColor:GetValue()
HexRaw = Dec2Hex(DecColor)
HexColor = string.sub(HexRaw, 3)
HexAlpha = string.sub(HexRaw, 1,2)
HexAlphaOpaque = "FF"

if Trans == 0
	then
	SKIN:Bang('!SetOption Background SolidColor '..HexColor..HexAlpha)
	else
	SKIN:Bang('!SetOption Background SolidColor '..HexColor..HexAlphaOpaque)
	end

return HexColor..HexAlpha
end



function Dec2Hex(nValue)
   -- Convert string to number if needed
   if type(nValue) == "string" then
      nValue = String.ToNumber(nValue);
   end
   nHexVal = string.format("%X", nValue);  -- %X returns uppercase hex, %x gives lowercase letters
   -- Convert number to string
   sHexVal = nHexVal.."";
   return sHexVal;
end
Now it detects the Taskbar color and if Transparency is "ON" or "OFF".

Thanks again !
Rainmeter - You are only limited by your imagination and creativity.
User avatar
jsmorley
Developer
Posts: 22620
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ColorizationColor convert to ...

Post by jsmorley »

Glad to help!