It is currently February 19th, 2020, 2:46 pm

Windows 10 Accent Color Matching (Updated - see link)

Discuss the use of Lua in Script measures.
DollarD
Posts: 16
Joined: March 2nd, 2013, 5:56 pm

Windows 10 Accent Color Matching (Updated - see link)

Post by DollarD »

UPDATE: Well, this is embarrassing. I blame sleep deprivation after doing just one last tweak on my skins at 3 AM, but still. This does not need lua at all. See here for my latest attempt: http://rainmeter.net/forum/viewtopic.php?f=15&t=21303

As recompense for my abuse of lua, please have some color manipulation code: http://rainmeter.net/forum/viewtopic.php?f=99&t=21304


Original post:
Since the Syscolor plugin does do this, I had to work around it.



First, create a .vbs file.

RegPalette.vbs:

Code: Select all

Set WshShell = CreateObject("WScript.Shell")
Set FSObj = CreateObject("Scripting.FileSystemObject")
FSObj.DeleteFile("C:\RegPalette.txt")
WshShell.Run "C:\Windows\System32\reg.exe export HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent C:\RegPalette.txt /y", 0
Set FSObj = Nothing
Set WshShell = Nothing
Then you're gonna need your skin:

Code: Select all

[Rainmeter]
Update=1000
....................................................................................................................................................

[Variables]
@Include="#CURRENTPATH#Variables.inc"
RegPalPath=C:\RegPalette.txt

........................................................................................................................................................

[MeasureAeroTrigger]
Measure=Plugin
Plugin=Plugin\SysColor.dll
ColorType=Aero 
Hex=1
DisplayType=ALL
OnChangeAction=[!UpdateMeasure "MeasureAeroRegistry"]
DynamicVariables=1
UpdateDivider=5

[MeasureAeroRegistry]
Measure=String
OnUpdateAction=["C:\Windows\System32\wscript.exe" //Nologo //B "C:\RegPalette.vbs"][!SetOption "MeasureRegExp" "UpdateDivider" "2"][!SetOption "MeasurePalette" "UpdateDivider" "2"][!UpdateMeasure "MeasureRegExp"][!UpdateMeasure "MeasurePalette"]
DynamicVariables=1
UpdateDivider=-1

[MeasureRegExp]
Measure=Plugin
Plugin=QuotePlugin
PathName=#RegAccPath#
OnChangeAction=[!SetOption "MeasureRegExp" "UpdateDivider" "-1"]
Separator=\t
DynamicVariables=1
UpdateDivider=-1

[MeasurePalette]
Measure=String
String=[MeasureRegExp]
DynamicVariables=1
RegExpSubstitute=1
Substitute="(?siU).*=hex:([[: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}),\\\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}).*":"\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"
OnChangeAction=[!UpdateMeasure "MeasureRegExp"][!UpdateMeasure "MeasureColorScript"][!SetOption "MeasurePalette" "UpdateDivider" "-1"][!Refresh]
UpdateDivider=-1

[MeasureColorScript]
Measure=Script
ScriptFile=Win10Color.lua
OnChangeAction=[!Update]
UpdateDivider=-1

And then some lua for text processing. Though you could do that with measures too I suppose.

Code: Select all

function Update()
	
	-- Get data from measure
	Palette = SKIN:GetMeasure('MeasurePalette'):GetStringValue()

	local Config = " "

	local WinTB = string.upper(string.sub(Palette,46 ,51))

	SKIN:Bang('!WriteKeyValue Variables WinTB     "' .. string.upper(WinTB)       .. '" ' .. SKIN:ReplaceVariables(' #IncFile# '))
		
SKIN:Bang('!SetVariable WinTB    "' .. string.upper(WinTB)     .. '" ' .. Config)

return

end
	
I still use the SysColor plugin to trigger the registry extract, since that seems less hungry on resources. And this is just for the taskbar - there's a palette available of you play around with the string.sub(Palette,46 ,51).

And all so it could do the following automatically:
(See attached)
You do not have the required permissions to view the files attached to this post.