erenaa wrote: ↑April 20th, 2021, 12:48 pm
Changing skin's theme to windows' theme
Windows' theme will not change
OK, it is possible to change the Windows theme too, but it should be fairly straightforward to have the skin change automatically. The code you posted is incomplete, but the basic idea is to read the registry setting you found and add "conditions" that will react to the value to adjust the skin accordingly.
You say you were able to read the registry to get the theme setting value. You can add code to that measure to react to the result. For example:
Code: Select all
; add a measure that will read the existing theme and convert the text value into a number you can use in logical expressions
[MeasureIsSkinLightTheme]
Measure=String
String=#BackgroundThemeName#
Substitute="Light":"1","Dark":"0"
UpdateDivider=-1
[MeasureIsWindowsLightTheme]
;
;... your existing code to read the value from HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme or SystemUsesLightTheme (whichever you want to check), then add the following:
;
; if windows is set to light and skin is set to dark, switch skin to light
IfCondition=([MeasureIsWindowsLightTheme] = 1) && ([MeasureIsSkinLightTheme] = 0)
IfTrueAction=[!WriteKeyValue Variables BackgroundThemeName "Light" #VariablesFilePath#][!WriteKeyValue Variables ForegroundThemeName "Dark" #VariablesFilePath#][!WriteKeyValue Variables BackgroundColorName "White" #VariablesFilePath#][!WriteKeyValue Variables ForegroundColorName "Black" #VariablesFilePath#][!Refresh]
; if windows is set to dark and skin is set to light, switch skin to dark
IfCondition2=([MeasureIsWindowsLightTheme] = 0) && ([MeasureIsSkinLightTheme] = 1)
IfTrueAction2=[!WriteKeyValue Variables BackgroundThemeName "Dark" #VariablesFilePath#][!WriteKeyValue Variables ForegroundThemeName "Light" #VariablesFilePath#][!WriteKeyValue Variables BackgroundColorName "Black" #VariablesFilePath#][!WriteKeyValue Variables ForegroundColorName "White" #VariablesFilePath#][!Refresh]
DynamicVariables=1
Don't use
[!RefreshApp] in your skin like in your snippet, that restarts Rainmeter and there is no need to do that. With a little extra effort, you can eliminate the
[!Refresh] and have the skin switch themes on the fly without refreshing completely, but you can try that once you get the above working. Don't forget to remove the context menu items, as they will not work anymore.
I didn't try the above code, so you might need to fix things, but the basic logic is there...