It is currently March 28th, 2024, 9:43 am

Change color set from measure 1 to measure 2 in a meter

Get help with creating, editing & fixing problems with skins
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Change color set from measure 1 to measure 2 in a meter

Post by pul53dr1v3r »

My intention is to keep the same color set range when i switch from measure 1 (metric) to measure 2 (imperial). Sth is wrong here with my solution but havent got what so far.

edit: read the following posts. This one was ugly!
Last edited by pul53dr1v3r on November 1st, 2019, 8:55 pm, edited 2 times in total.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change color set from measure 1 to measure 2 in a meter

Post by balala »

Could you please post the WHOLE code, not just pieces?
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Change color set from measure 1 to measure 2 in a meter

Post by pul53dr1v3r »

i got it working but only AFTER A MANUAL SKIN REFRESH. How to solve it if possible?
It show different colorst until the skin is refreshed by hands.
This is the current part of the code:

Code: Select all

[Variables]
Link=https://weather.com/#Lang#/weather/today/l/
Link2=https://weather.com/#Lang#/weather/tenday/l/
URL=#Link##locationCode#
URL2=#Link2##locationCode#
WeatherTempColor=205,255,0
WeatherTempColor2=0,128,255
Lang=en-GB

[MeasureNow]
Measure=WebParser
Url=#URL#
RegExp=#NOW#
UpdateRate=#UpRate#
LogSubstringErrors=0
FinishAction=[!EnableMeasureGroup Weather][!UpdateMeasureGroup Weather][!UpdateMeterGroup Weather][!UpdateMeterGroup Background][!Redraw]

[MeasureNowTemp]
Measure=WebParser
Url=[MeasureNow]
StringIndex=4
Substitute="":"--"
Group=Weather
Disabled=1

[MeasureUnitsFormat]
Measure=String
String=#Lang#
IfMatch=en-GB
IfMatchAction=[!EnableMeasure "MeasureNowMetricTempColors"][!DisableMeasure "MeasureNowImperialTempColors"][!SetOption "MeterCurrentTemperature" "FontColor" "#WeatherTempColor#"][!UpdateMeter "MeterCurrentTemperature"][!Redraw]
IfMatch2=en-US
IfMatchAction2=[!DisableMeasure "MeasureNowMetricTempColors"][!EnableMeasure "MeasureNowImperialTempColors"][!SetOption "MeterCurrentTemperature" "FontColor" "#WeatherTempColor2#"][!UpdateMeter "MeterCurrentTemperature"][!Redraw]
;OnChangeAction=[!RefreshGroup "Weather"][!UpdateMeter "MeterCurrentTemperature"][!UpdateMeasure "MeasureNowMetricTempColors"][!UpdateMeasure "MeasureNowImperialTempColors"]
DynamicVariables=1

[MeasureNowMetricTempColors]
Measure=Calc
Formula=MeasureNowTemp
IfCondition=(#CURRENTSECTION#<=-35)
IfTrueAction=[!WriteKeyValue "Variables" "WeatherTempColor" "255,255,255"][!SetVariable "WeatherTempColor" "255,255,255"]
IfCondition2=((#CURRENTSECTION#>-35)&&(#CURRENTSECTION#<=-30))
IfTrueAction2=[!WriteKeyValue "Variables" "WeatherTempColor" "254,220,237"][!SetVariable "WeatherTempColor" "254,220,237"]
IfCondition3=((#CURRENTSECTION#>-30)&&(#CURRENTSECTION#<=-25))
IfTrueAction3=[!WriteKeyValue "Variables" "WeatherTempColor" "255,123,172"][!SetVariable "WeatherTempColor" "255,123,172"]
IfCondition4=((#CURRENTSECTION#>-25)&&(#CURRENTSECTION#<=-20))
IfTrueAction4=[!WriteKeyValue "Variables" "WeatherTempColor" "255,0,254"][!SetVariable "WeatherTempColor" "255,0,254"]
IfCondition5=((#CURRENTSECTION#>-20)&&(#CURRENTSECTION#<=-15))
IfTrueAction5=[!WriteKeyValue "Variables" "WeatherTempColor" "138,43,226"][!SetVariable "WeatherTempColor" "138,43,226"]
IfCondition6=((#CURRENTSECTION#>-15)&&(#CURRENTSECTION#<=-10))
IfTrueAction6=[!WriteKeyValue "Variables" "WeatherTempColor" "0,128,255"][!SetVariable "WeatherTempColor" "0,128,255"]
IfCondition7=((#CURRENTSECTION#>-10)&&(#CURRENTSECTION#<=-5))
IfTrueAction7=[!WriteKeyValue "Variables" "WeatherTempColor" "0,204,255"][!SetVariable "WeatherTempColor" "0,204,255"]
IfCondition8=((#CURRENTSECTION#>-5)&&(#CURRENTSECTION#<=0))
IfTrueAction8=[!WriteKeyValue "Variables" "WeatherTempColor" "5,247,248"][!SetVariable "WeatherTempColor" "5,247,248"]
IfCondition9=((#CURRENTSECTION#>0)&&(#CURRENTSECTION#<=5))
IfTrueAction9=[!WriteKeyValue "Variables" "WeatherTempColor" "128,255,0"][!SetVariable "WeatherTempColor" "128,255,0"]
IfCondition10=((#CURRENTSECTION#>5)&&(#CURRENTSECTION#<=10))
IfTrueAction10=[!WriteKeyValue "Variables" "WeatherTempColor" "205,255,0"][!SetVariable "WeatherTempColor" "205,255,0"]
IfCondition11=((#CURRENTSECTION#>10)&&(#CURRENTSECTION#<=15))
IfTrueAction11=[!WriteKeyValue "Variables" "WeatherTempColor" "255,255,1"][!SetVariable "WeatherTempColor" "255,255,1"]
IfCondition12=((#CURRENTSECTION#>15)&&(#CURRENTSECTION#<=20))
IfTrueAction12=[!WriteKeyValue "Variables" "WeatherTempColor" "255,215,40"][!SetVariable "WeatherTempColor" "255,215,40"]
IfCondition13=((#CURRENTSECTION#>20)&&(#CURRENTSECTION#<=25))
IfTrueAction13=[!WriteKeyValue "Variables" "WeatherTempColor" "255,158,7"][!SetVariable "WeatherTempColor" "255,158,7"]
IfCondition14=((#CURRENTSECTION#>25)&&(#CURRENTSECTION#<=30))
IfTrueAction14=[!WriteKeyValue "Variables" "WeatherTempColor" "244,101,35"][!SetVariable "WeatherTempColor" "244,101,35"]
IfCondition15=((#CURRENTSECTION#>30)&&(#CURRENTSECTION#<=35))
IfTrueAction15=[!WriteKeyValue "Variables" "WeatherTempColor" "250,0,0"][!SetVariable "WeatherTempColor" "250,0,0"]
IfCondition16=((#CURRENTSECTION#>35)&&(#CURRENTSECTION#<=40))
IfTrueAction16=[!WriteKeyValue "Variables" "WeatherTempColor" "180,0,0"][!SetVariable "WeatherTempColor" "180,0,0"]
IfCondition17=(#CURRENTSECTION#>40)
IfTrueAction17=[!WriteKeyValue "Variables" "WeatherTempColor" "135,0,0"][!SetVariable "WeatherTempColor" "135,0,0"]
Group=Weather
Disabled=1
DynamicVariables=1

[MeasureNowImperialTempColors]
Measure=Calc
Formula=MeasureNowTemp
IfCondition=(#CURRENTSECTION#<=-31)
IfTrueAction=[!WriteKeyValue "Variables" "WeatherTempColor2" "255,255,255"][!SetVariable "WeatherTempColor2" "255,255,255"]
IfCondition2=((#CURRENTSECTION#>-31)&&(#CURRENTSECTION#<=-22))
IfTrueAction2=[!WriteKeyValue "Variables" "WeatherTempColor2" "254,220,237"][!SetVariable "WeatherTempColor2" "254,220,237"]
IfCondition3=((#CURRENTSECTION#>-22)&&(#CURRENTSECTION#<=-13))
IfTrueAction3=[!WriteKeyValue "Variables" "WeatherTempColor2" "255,123,172"][!SetVariable "WeatherTempColor2" "255,123,172"]
IfCondition4=((#CURRENTSECTION#>-13)&&(#CURRENTSECTION#<=-4))
IfTrueAction4=[!WriteKeyValue "Variables" "WeatherTempColor2" "255,0,254"][!SetVariable "WeatherTempColor2" "255,0,254"]
IfCondition5=((#CURRENTSECTION#>-4)&&(#CURRENTSECTION#<=5))
IfTrueAction5=[!WriteKeyValue "Variables" "WeatherTempColor2" "138,43,226"][!SetVariable "WeatherTempColor2" "138,43,226"]
IfCondition6=((#CURRENTSECTION#>5)&&(#CURRENTSECTION#<=14))
IfTrueAction6=[!WriteKeyValue "Variables" "WeatherTempColor2" "0,128,255"][!SetVariable "WeatherTempColor2" "0,128,255"]
IfCondition7=((#CURRENTSECTION#>14)&&(#CURRENTSECTION#<=23))
IfTrueAction7=[!WriteKeyValue "Variables" "WeatherTempColor2" "0,204,255"][!SetVariable "WeatherTempColor2" "0,204,255"]
IfCondition8=((#CURRENTSECTION#>23)&&(#CURRENTSECTION#<=32))
IfTrueAction8=[!WriteKeyValue "Variables" "WeatherTempColor2" "5,247,248"][!SetVariable "WeatherTempColor2" "5,247,248"]
IfCondition9=((#CURRENTSECTION#>32)&&(#CURRENTSECTION#<=41))
IfTrueAction9=[!WriteKeyValue "Variables" "WeatherTempColor2" "128,255,0"][!SetVariable "WeatherTempColor2" "128,255,0"]
IfCondition10=((#CURRENTSECTION#>41)&&(#CURRENTSECTION#<=50))
IfTrueAction10=[!WriteKeyValue "Variables" "WeatherTempColor2" "205,255,0"][!SetVariable "WeatherTempColor2" "205,255,0"]
IfCondition11=((#CURRENTSECTION#>50)&&(#CURRENTSECTION#<=59))
IfTrueAction11=[!WriteKeyValue "Variables" "WeatherTempColor2" "255,255,1"][!SetVariable "WeatherTempColor2" "255,255,1"]
IfCondition12=((#CURRENTSECTION#>59)&&(#CURRENTSECTION#<=68))
IfTrueAction12=[!WriteKeyValue "Variables" "WeatherTempColor2" "255,215,40"][!SetVariable "WeatherTempColor2" "255,215,40"]
IfCondition13=((#CURRENTSECTION#>68)&&(#CURRENTSECTION#<=77))
IfTrueAction13=[!WriteKeyValue "Variables" "WeatherTempColor2" "255,158,7"][!SetVariable "WeatherTempColor2" "255,158,7"]
IfCondition14=((#CURRENTSECTION#>77)&&(#CURRENTSECTION#<=86))
IfTrueAction14=[!WriteKeyValue "Variables" "WeatherTempColor2" "244,101,35"][!SetVariable "WeatherTempColor2" "244,101,35"]
IfCondition15=((#CURRENTSECTION#>86)&&(#CURRENTSECTION#<=95))
IfTrueAction15=[!WriteKeyValue "Variables" "WeatherTempColor2" "250,0,0"][!SetVariable "WeatherTempColor2" "250,0,0"]
IfCondition16=((#CURRENTSECTION#>95)&&(#CURRENTSECTION#<=104))
IfTrueAction16=[!WriteKeyValue "Variables" "WeatherTempColor2" "180,0,0"][!SetVariable "WeatherTempColor2" "180,0,0"]
IfCondition17=(#CURRENTSECTION#>104)
IfTrueAction17=[!WriteKeyValue "Variables" "WeatherTempColor2" "135,0,0"][!SetVariable "WeatherTempColor2" "135,0,0"]
Group=Weather
Disabled=1
DynamicVariables=1

[MeterCurrentTemperature]
Meter=String
MeasureName=MeasureNowTemp
MeterStyle=styleFirstLineText | StyleCenterAlign
Text=%1
Group=Weather
UpdateDivider=-1
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change color set from measure 1 to measure 2 in a meter

Post by balala »

Pul53dr1v3r wrote: October 31st, 2019, 9:01 pm i got it working but only AFTER A MANUAL SKIN REFRESH. How to solve it if possible?
It show different colorst until the skin is refreshed by hands.
This is the current part of the code:
Add some !SetVariable bangs beside the !WriteKeyValues. The !WriteKeyValue bangs are writing the appropriate colors into the [Variables] section, as the WeatherTempColor variable, but the skin can't use this value, unless you're adding the !SetVariable bangs, to dynamically set those variables as well (or you are refreshing the skin - but this is what you want to avoid, right?): https://forum.rainmeter.net/viewtopic.php?f=5&t=22739&p=120238&hilit=refresh+balala+destructive#p120238
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Change color set from measure 1 to measure 2 in a meter

Post by pul53dr1v3r »

balala wrote: October 31st, 2019, 9:15 pm Add some !SetVariable bangs beside the !WriteKeyValues. The !WriteKeyValue bangs are writing the appropriate colors into the [Variables] section, as the WeatherTempColor variable, but the skin can't use this value, unless you're adding the !SetVariable bangs, to dynamically set those variables as well (or you are refreshing the skin - but this is what you want to avoid, right?): https://forum.rainmeter.net/viewtopic.php?f=5&t=22739&p=120238&hilit=refresh+balala+destructive#p120238
haven't i added it?
one line as example:
IfTrueAction=[!WriteKeyValue "Variables" "WeatherTempColor" "255,255,255"][!SetVariable "WeatherTempColor" "255,255,255"]
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change color set from measure 1 to measure 2 in a meter

Post by balala »

Pul53dr1v3r wrote: October 31st, 2019, 9:27 pm haven't i added it?
one line as example:
Sorry, yes, you've added.
Please pack the whole config you have and upload the package. Would be much easier to check it.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Change color set from measure 1 to measure 2 in a meter

Post by pul53dr1v3r »

balala wrote: October 31st, 2019, 9:37 pm Sorry, yes, you've added.
Please pack the whole config you have and upload the package. Would be much easier to check it.
Ok. Finally here is the package: download

Use the settings panel to switch between the units formats.

Image
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change color set from measure 1 to measure 2 in a meter

Post by balala »

Pul53dr1v3r wrote: November 1st, 2019, 11:00 am Finally here is the package: download
  1. There is no need to use two WeatherTempColor variables (WeatherTempColor and WeatherTempColor2 respectively). One is completely enough. Depending on the unit you're using, you have to set the value of this variable, through one of the [MeasureNowMetricTempColors] or [MeasureNowImperialTempColors] measures. The other has to be disabled. You can do this through the IfMatchAction and IfMatchAction2 options of the [MeasureUnitsFormat] measure. Replace these options with the following ones:

    Code: Select all

    [MeasureUnitsFormat]
    ...
    IfMatchAction=[!EnableMeasure "MeasureNowMetricTempColors"][!DisableMeasure "MeasureNowImperialTempColors"]
    ...
    IfMatchAction2=[!DisableMeasure "MeasureNowMetricTempColors"][!EnableMeasure "MeasureNowImperialTempColors"]
    This way if metric system is set the [MeasureNowMetricTempColors] measure will work and the bangs of the appropriate IfTrueAction option set and write the color. If on the other hand the imperial system is set [MeasureNowImperialTempColors] is enabled and its bangs set / write the appropriate value of the WeatherTempColor variable. In both cases the other measure ([MeasureNowImperialTempColors] in first case, respectively [MeasureNowMetricTempColors] in second case) is disabled, so its IfConditions are not executed, not setting the variable.
  2. The temperature is returned by a WebParser measure ([MeasureNowTemp]) and even if it returns a numeric value (like this time), this value can't be used by Calc measures, unless it is converted appropriately. So you have to replace the old Formula option of the [MeasureNowMetricTempColors] and [MeasureNowImperialTempColors] measures with this: Formula=[MeasureNowTemp] (the measures would also require to add a DynamicVariables=1 option, but these are already added, so this is ok).
  3. Another thing you have to do is to set both set of bangs (!WriteKeyValue and !SetVariable) of the IfTrueAction options of the [MeasureNowImperialTempColors] measure to set not the value of the WeatherTempColor2 variable but of the WeatherTempColor variable instead. So replace WeatherTempColor2 in all those bangs with WeatherTempColor. For instance:

    Code: Select all

    [MeasureNowImperialTempColors]
    ...
    IfCondition=(#CURRENTSECTION#<=-31)
    IfTrueAction=[!WriteKeyValue Variables WeatherTempColor "255,255,255"][!SetVariable WeatherTempColor "255,255,255"][!UpdateMeasure "MeasureUnitsFormat"]
    IfCondition2=((#CURRENTSECTION#>-31)&&(#CURRENTSECTION#<=-22))
    IfTrueAction2=[!WriteKeyValue Variables WeatherTempColor "254,220,237"][!SetVariable WeatherTempColor "254,220,237"][!UpdateMeasure "MeasureUnitsFormat"]
    ...
    (obviously take care there are 17 IfConditions and the appropriate 17 IfTrueActions. Modify all of them). Since anyway one of these measures is disabled, this isn1t a problem.
  4. Also remove the [!EnableMeasureGroup Weather] bang from the FinishAction option of the [MeasureNow] measure, because one of the [MeasureNowMetricTempColors] and [MeasureNowImperialTempColors] measures is anyway enabled through the [MeasureUnitsFormat] measure (see above) and the other has to be kept disabled.
  5. Finally add the #WeatherTempColor# variable into the FontColor option of the [MeterCurrentTemperature] meter:

    Code: Select all

    [MeterCurrentTemperature]
    ...
    FontColor=#WeatherTempColor#
Does this solution work appropriately?
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Change color set from measure 1 to measure 2 in a meter

Post by pul53dr1v3r »

balala wrote: November 1st, 2019, 6:46 pm
it does work like a charm! :rosegift:
I used the second variable more in desperation when none of the previously tried solutions hadn't worked. But after all, when i sum up all this, the biggest mistake was not using the square brackets in the Formulas. I mixed many of the solutions but never used them. Unbelieveable, but i didn't know i need it. O.O But with only [MeasureNowMetricTempColors] it worked well, before i added the measure for imperial units. How it worked then? I used [!SetOption MeterCurrentTemperature FontColor... in the measure instead of tackling with variables.

One more question. If you haven't noticed, when you quickly refresh the skin for 2 or more times, it stops working until i re-open Rainmeter. I should be cause by WebParser working issue. You can use middle mouse btn to refresh it quickly to see the issue.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change color set from measure 1 to measure 2 in a meter

Post by balala »

Pul53dr1v3r wrote: November 1st, 2019, 7:34 pm I used the second variable more in desperation when none of the previously tried solutions hadn't worked.
As said, no need of it. Can be used, but in my opinion is much simpler to avoid it (as you probably noticed).
Pul53dr1v3r wrote: November 1st, 2019, 7:34 pm But after all, when i sum up all this, the biggest mistake was not using the square brackets in the Formulas. I mixed many of the solutions but never used them. Unbelieveable, but i didn't know i need it.
Yep, this is not a widely known thing. I suppose the value returned by a WebParser measure is a string, even if it has a numeric value. To convert it, you have to include it into those brackets, along with setting the dynamic variables.
Pul53dr1v3r wrote: November 1st, 2019, 7:34 pm But with only [MeasureNowMetricTempColors] it worked well, before i added the measure for imperial units. How it worked then? I used [!SetOption MeterCurrentTemperature FontColor... in the measure instead of tackling with variables.
I'm not sure and can't say, since I don't know the "simpler" code, with only one measure. :confused:
Pul53dr1v3r wrote: November 1st, 2019, 7:34 pm One more question. If you haven't noticed, when you quickly refresh the skin for 2 or more times, it stops working until i re-open Rainmeter. I should be cause by WebParser working issue. You can use middle mouse btn to refresh it quickly to see the issue.
This is a known issue of WebParser measures: https://forum.rainmeter.net/viewtopic.php?f=5&t=26117&p=136507&hilit=hang+webparser#p136507
Post Reply