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

Value change icon

Get help with creating, editing & fixing problems with skins
PtitChat107
Posts: 126
Joined: December 31st, 2015, 6:40 pm

Value change icon

Post by PtitChat107 »

Hi,
I know my title is not very good, but I will try to be more explicit; I would like to know if it would be possible to set up a sort of icon (in my case the characters U+25B2 and U+25BC) changing next to a result retrieved by RegExp.
As an example; I retrieve data in the form of a number (for example 15) and display it on my Skin; so far, everything is normal and nothing more is displayed.
Temp. 15 (●)
Then the same number increases to 17, in this case the skin will have this display:
Temp. 17 (▲)
And if the data goes down, it will give this:
Temp. 9 (▼)
Then to finish if the value has not changed during the next update of the data:
Temp. 9 (▬)
It would be necessary that my data could be stored on a temporary file then to be analyzed for the future display of the icon. I readily admit that this seems complicated, but I await your opinion on the subject, see a little help to start. :oops:
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Value change icon

Post by jsmorley »

I'd probably attack it something like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
PrevValue=0
DirIcon=●

[MeasureTemp]
Measure=WebParser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)<temp>(.*)</temp>
StringIndex=1
UpdateRate=5
FinishAction=[!EnableMeasure MeasurePrev][!UpdateMeasure MeasurePrev]

[MeasurePrev]
Measure=Calc
Formula=[MeasureTemp]
DynamicVariables=1
Disabled=1
UpdateDivider=-1
IfCondition=#PrevValue# > [MeasureTemp]
IfTrueAction=[!SetVariable DirIcon "▼"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]
IfCondition2=#PrevValue# < [MeasureTemp]
IfTrueAction2=[!SetVariable DirIcon "▲"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]
IfCondition3=#PrevValue# = [MeasureTemp]
IfTrueAction3=[!SetVariable DirIcon "▬"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]

[MeterTemp]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Temperature: [MeasureTemp] (#DirIcon#)
DynamicVariables=1
So basically when the WebParser measure gets the value, it is compared to the variable #PrevValue#. If #PrevValue# is "greater", than the current temperature is "lower", and the string "▼" is set for a variable #DirIcon#, and used in the string meter. Same thing for "lower" and "equal".

Then the current value from WebParser is set as the value for #PrevValue#, ready for the comparison the next time WebParser goes out and gets a value. At the same time, we are physically writing the value of #PrevValue#, so it will be "persistent", and survive a refresh or restart of the skin.

This test skin just uses a local file to simulate getting the temperature from some weather site, and can be tested by opening Test.html, changing the value in it, and saving. I have it set to read the file every 5 seconds, just for testing purposes.

Test.html:

Code: Select all

<temp>70</temp>
If you are going to directly use the Unicode characters in your skin .ini code, be sure the file is encoded as UTF-16 LE. You can also use Inline Character Variables instead if you want.
PtitChat107
Posts: 126
Joined: December 31st, 2015, 6:40 pm

Re: Value change icon

Post by PtitChat107 »

jsmorley wrote:If you are going to directly use the Unicode characters in your skin .ini code, be sure the file is encoded as UTF-16 LE. You can also use Inline Character Variables instead if you want.
It works from thunder, thank you so much! That said, I'll look in detail, see if there is not a possibility to add a unique color to each icon (red, green and blue for example) to have a more visual result.

Edit .: I leave you the example on which I work so that you can make your opinion, I had some failures on my side where the icon did not seem to change whereas the sum had diminished.

Code: Select all

[Rainmeter]
Update=1000

[Variables]
fontName=Trebuchet MS
textSize=8
colorBar=235,170,0,255
colorText=255,255,255,205
PrevValue=5329.4
DirIcon=●

; ----------------------------------
; MEASURES
; ----------------------------------

[measureTime]
Measure=Time
Format=%H:%M:%S

[measureBitcoin]
Measure=Plugin
Plugin=WebParser
Url=https://api.cryptowat.ch/markets/kraken/btceur/price
UpdateRate=30
StringIndex=1
RegExp=(?siU){"result":{"price":(.*)},"allowance".*
FinishAction=[!EnableMeasure MeasureBitcoinPrev][!UpdateMeasure MeasureBitcoinPrev]

[MeasureBitcoinPrev]
Measure=Calc
Formula=[measureBitcoin]
DynamicVariables=1
Disabled=1
UpdateDivider=-1
IfCondition=#PrevValue# > [measureBitcoin]
IfTrueAction=[!SetVariable DirIcon "▼"][!SetVariable PrevValue "[measureBitcoin]"][!WriteKeyValue Variables PrevValue "[measureBitcoin]"][!UpdateMeter *][!Redraw]
IfCondition2=#PrevValue# < [measureBitcoin]
IfTrueAction2=[!SetVariable DirIcon "▲"][!SetVariable PrevValue "[measureBitcoin]"][!WriteKeyValue Variables PrevValue "[measureBitcoin]"][!UpdateMeter *][!Redraw]
IfCondition3=#PrevValue# = [measureBitcoin]
IfTrueAction3=[!SetVariable DirIcon "▬"][!SetVariable PrevValue "[measureBitcoin]"][!WriteKeyValue Variables PrevValue "[measureBitcoin]"][!UpdateMeter *][!Redraw]
; ----------------------------------
; STYLES are used to "centralize" options
; ----------------------------------

[styleTitle]
StringAlign=Center
StringCase=Upper
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,50
FontColor=#colorText#
FontFace=#fontName#
FontSize=10
AntiAlias=1
ClipString=1

[styleLeftText]
StringAlign=Left
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleRightText]
StringAlign=Right
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

; ----------------------------------
; METERS
; ----------------------------------

[meterTitle]
Meter=String
MeterStyle=styleTitle
MeasureName=measureTime
X=100
Y=12
W=190
H=18
Text=%1

[meterLabelBitcoin]
Meter=String
MeterStyle=styleLeftText
X=10
Y=80
W=190
H=14
Text=Bitcoin

[meterValueBitcoin]
Meter=String
MeasureName=measureBitcoin
MeterStyle=styleRightText
X=200
Y=80
StringAlign=Right
AntiAlias=1
DynamicVariables=1
Text=[measureBitcoin] € #DirIcon#
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Value change icon

Post by xenium »

jsmorley wrote:I'd probably attack it something like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
PrevValue=0
DirIcon=●

[MeasureTemp]
Measure=WebParser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)<temp>(.*)</temp>
StringIndex=1
UpdateRate=5
FinishAction=[!EnableMeasure MeasurePrev][!UpdateMeasure MeasurePrev]

[MeasurePrev]
Measure=Calc
Formula=[MeasureTemp]
DynamicVariables=1
Disabled=1
UpdateDivider=-1
IfCondition=#PrevValue# > [MeasureTemp]
IfTrueAction=[!SetVariable DirIcon "▼"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]
IfCondition2=#PrevValue# < [MeasureTemp]
IfTrueAction2=[!SetVariable DirIcon "▲"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]
IfCondition3=#PrevValue# = [MeasureTemp]
IfTrueAction3=[!SetVariable DirIcon "▬"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]

[MeterTemp]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Temperature: [MeasureTemp] (#DirIcon#)
DynamicVariables=1
So basically when the WebParser measure gets the value, it is compared to the variable #PrevValue#. If #PrevValue# is "greater", than the current temperature is "lower", and the string "▼" is set for a variable #DirIcon#, and used in the string meter. Same thing for "lower" and "equal".

Then the current value from WebParser is set as the value for #PrevValue#, ready for the comparison the next time WebParser goes out and gets a value. At the same time, we are physically writing the value of #PrevValue#, so it will be "persistent", and survive a refresh or restart of the skin.

This test skin just uses a local file to simulate getting the temperature from some weather site, and can be tested by opening Test.html, changing the value in it, and saving. I have it set to read the file every 5 seconds, just for testing purposes.

Test.html:

Code: Select all

<temp>70</temp>
If you are going to directly use the Unicode characters in your skin .ini code, be sure the file is encoded as UTF-16 LE. You can also use Inline Character Variables instead if you want.
I tried to use the jsmorley code to show the temperature evolution but it does not work because the temperature value is accompanied by the + and - signs.
I tried to add + sign to Prevalue's value but it does not work
Is there a solution?
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Value change icon

Post by balala »

xenium wrote:I tried to use the jsmorley code to show the temperature evolution but it does not work because the temperature value is accompanied by the + and - signs.
I tried to add + sign to Prevalue's value but it does not work
Is there a solution?
This shouldn't have to be a problem, I think, because that code should have to work with both positive and negative values (well, it's true I didn't make a try).
Please post the code you are using.
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Value change icon

Post by xenium »

balala wrote:This shouldn't have to be a problem, I think, because that code should have to work with both positive and negative values (well, it's true I didn't make a try).
Please post the code you are using.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
PrevValue=0
DirIcon=●

UpdateRateSeconds=600


URL=https://www.foreca.com/Canada/Quebec/Montreal

=======================================================

[MeasureTemp]
Measure=WebParser
Url=#URL#
RegExp=(?siU)<span class=".* txt-xxlarge"><strong>(.*)</strong>
UpdateRate=#UpdateRateSeconds#
StringIndex=1
FinishAction=[!EnableMeasure MeasurePrev][!UpdateMeasure MeasurePrev]

[MeasurePrev]
Measure=Calc
Formula=[MeasureTemp]
DynamicVariables=1
Disabled=1
UpdateDivider=-1
IfCondition=#PrevValue# > [MeasureTemp]
IfTrueAction=[!SetVariable DirIcon "▼"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]
IfCondition2=#PrevValue# < [MeasureTemp]
IfTrueAction2=[!SetVariable DirIcon "▲"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]
IfCondition3=#PrevValue# = [MeasureTemp]
IfTrueAction3=[!SetVariable DirIcon "▬"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]

[MeterTemp]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Temperature: [MeasureTemp] (#DirIcon#)
DynamicVariables=1
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Value change icon

Post by FreeRaider »

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
PrevValue=-31
DirIcon=●

UpdateRateSeconds=600


URL=https://www.foreca.com/Canada/Quebec/Montreal

; =======================================================

[MeasureTemp]
Measure=Plugin
Plugin=WebParser
Url=#URL#
RegExp=(?siU)<span class=".* txt-xxlarge"><strong>(.*)</strong>
UpdateRate=#UpdateRateSeconds#
StringIndex=1
RegExpSubstitute=1
Substitute="^\+(.*)":"\1","^\-(.*)":"-\1"
FinishAction=[!EnableMeasure MeasurePrev][!UpdateMeasure MeasurePrev]

[MeasurePrev]
Measure=Calc
Formula=[MeasureTemp]
DynamicVariables=1
Disabled=1
UpdateDivider=-1
IfCondition=#PrevValue# > [MeasureTemp]
IfTrueAction=[!SetVariable DirIcon "▼"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]
IfCondition2=#PrevValue# < [MeasureTemp]
IfTrueAction2=[!SetVariable DirIcon "▲"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]
IfCondition3=#PrevValue# = [MeasureTemp]
IfTrueAction3=[!SetVariable DirIcon "▬"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]

[MeterTemp]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Temperature: [MeasureTemp] (#DirIcon#)
DynamicVariables=1
I have added in [MeasuseTemp] these lines:
RegExpSubstitute=1
Substitute="^\+(.*)":"\1","^\-(.*)":"-\1"

Try it and tell us if it works
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Value change icon

Post by FreeRaider »

PtitChat107 wrote:It works from thunder, thank you so much! That said, I'll look in detail, see if there is not a possibility to add a unique color to each icon (red, green and blue for example) to have a more visual result.

Edit .: I leave you the example on which I work so that you can make your opinion, I had some failures on my side where the icon did not seem to change whereas the sum had diminished.
For the color, you can use inline options in your IfCondition statements.

Code: Select all

[Rainmeter]
Update=1000

[Variables]
fontName=Trebuchet MS
textSize=8
colorBar=235,170,0,255
colorText=255,255,255,205
PrevValue=5446.2
DirIcon=●

; ----------------------------------
; MEASURES
; ----------------------------------

[measureTime]
Measure=Time
Format=%H:%M:%S

[measureBitcoin]
Measure=Plugin
Plugin=WebParser
Url=https://api.cryptowat.ch/markets/kraken/btceur/price
UpdateRate=30
StringIndex=1
RegExp=(?siU){"result":{"price":(.*)},"allowance".*
FinishAction=[!EnableMeasure MeasureBitcoinPrev][!UpdateMeasure MeasureBitcoinPrev]

[MeasureBitcoinPrev]
Measure=Calc
Formula=[measureBitcoin]
DynamicVariables=1
Disabled=1
UpdateDivider=-1
IfCondition=#PrevValue# > [measureBitcoin]
IfTrueAction=[!SetVariable DirIcon "▼"][!SetOption meterValueBitcoin InlineSetting "Color | 255,0,0,255"][!SetOption meterValueBitcoin InlinePattern "^.* € (.)$"][!SetVariable PrevValue "[measureBitcoin]"][!WriteKeyValue Variables PrevValue "[measureBitcoin]"][!UpdateMeter *][!Redraw]
IfCondition2=#PrevValue# < [measureBitcoin]
IfTrueAction2=[!SetVariable DirIcon "▲"][!SetOption meterValueBitcoin InlineSetting "Color | 0,255,0,255"][!SetOption meterValueBitcoin InlinePattern "^.* € (.)$"][!SetVariable PrevValue "[measureBitcoin]"][!WriteKeyValue Variables PrevValue "[measureBitcoin]"][!UpdateMeter *][!Redraw]
IfCondition3=#PrevValue# = [measureBitcoin]
IfTrueAction3=[!SetVariable DirIcon "▬"][!SetOption meterValueBitcoin InlineSetting "Color | 255,255,255,255"][!SetOption meterValueBitcoin InlinePattern "^.* € (.)$"][!SetVariable PrevValue "[measureBitcoin]"][!WriteKeyValue Variables PrevValue "[measureBitcoin]"][!UpdateMeter *][!Redraw]
; ----------------------------------
; STYLES are used to "centralize" options
; ----------------------------------

[styleTitle]
StringAlign=Center
StringCase=Upper
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,50
FontColor=#colorText#
FontFace=#fontName#
FontSize=10
AntiAlias=1
ClipString=1

[styleLeftText]
StringAlign=Left
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleRightText]
StringAlign=Right
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

; ----------------------------------
; METERS
; ----------------------------------

[meterTitle]
Meter=String
MeterStyle=styleTitle
MeasureName=measureTime
X=100
Y=12
W=190
H=18
Text=%1

[meterLabelBitcoin]
Meter=String
MeterStyle=styleLeftText
X=10
Y=80
W=190
H=14
Text=Bitcoin

[meterValueBitcoin]
Meter=String
MeasureName=measureBitcoin
MeterStyle=styleRightText
X=200
Y=80
StringAlign=Right
AntiAlias=1
DynamicVariables=1
InlinePattern=^$
InlineSetting=None
Text=[measureBitcoin] € #DirIcon#
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Value change icon

Post by xenium »

FreeRaider wrote: I have added in [MeasuseTemp] these lines:
RegExpSubstitute=1
Substitute="^\+(.*)":"\1","^\-(.*)":"-\1"

Try it and tell us if it works
For positive temperatures, the + sign does not appear and I would like to keep it.
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Value change icon

Post by FreeRaider »

New code (I hope this is what you would like to have)

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
PrevValue=25
DirIcon=●

UpdateRateSeconds=600


URL=https://www.foreca.com/Canada/Quebec/Montreal

; =======================================================

[MeasureTemp]
Measure=Plugin
Plugin=WebParser
Url=#URL#
RegExp=(?siU)<span class=".* txt-xxlarge"><strong>(.*)</strong>
UpdateRate=#UpdateRateSeconds#
StringIndex=1
RegExpSubstitute=1
Substitute="^\+(.*)":"\1","^\-(.*)":"-\1"
FinishAction=[!EnableMeasure MeasurePrev][!UpdateMeasure MeasurePrev]
DynamicVariables=1

[MeasurePrev]
Measure=Calc
Formula=SGN([MeasureTemp])
Substitute="1":"+","-1":"-","0":""
DynamicVariables=1
Disabled=1
UpdateDivider=-1
IfCondition=#PrevValue# > [MeasureTemp]
IfTrueAction=[!SetVariable DirIcon "▼"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]
IfCondition2=#PrevValue# < [MeasureTemp]
IfTrueAction2=[!SetVariable DirIcon "▲"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]
IfCondition3=#PrevValue# = [MeasureTemp]
IfTrueAction3=[!SetVariable DirIcon "▬"][!SetVariable PrevValue "[MeasureTemp]"][!WriteKeyValue Variables PrevValue "[MeasureTemp]"][!UpdateMeter *][!Redraw]

[MeterTemp]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Temperature:  [MeasurePrev][MeasureTemp] (#DirIcon#)
DynamicVariables=1
Post Reply