It is currently March 28th, 2024, 2:27 pm

Hard drive roundline meter color change

Get help with creating, editing & fixing problems with skins
Post Reply
JusMu
Posts: 2
Joined: February 21st, 2018, 11:59 am

Hard drive roundline meter color change

Post by JusMu »

Hey. I'm working on my own skin and i just haven't have any luck with this. I'm pretty new to this rainmeter.

So problem is that i try to make roundline meter for my harddrive so that used space is colored and it changes color depending how much space is used. This part of the skin is on attachments. There you can see how it looks. Now it just shows black circle if i turn of used and pointer meters. Colors are just some values and I'm gonna change them if i get this one to work first.

So i tried to use "measure=calc,formula" options to read used space as %. I have checked many forums posts and tried many different things without any luck.

Code at this point:

Code: Select all


[Rainmeter]
Update=1000

BackgroundMode=2
SolidColor=#Color3#


[Metadata]
Name=Tsekataan
Author=JusMu
Information=Testiä katsoa jos sais jotain cool aikaiseksi
Version=0.1
License=Iha oma


;--------------------------------------------
;--------------------------------------------
;--------------------------------------------
; Variables
;--------------------------------------------
;--------------------------------------------
;--------------------------------------------

[Variables]

FontColor1=255,100,100,255
Color1=0,0,32,128
Color2=255,255,255,255
;Valkea
Color3=0,0,0,128
;--------------------------------------------
;--------------------------------------------
;--------------------------------------------
; MeterStyles
;--------------------------------------------
;--------------------------------------------
;--------------------------------------------

[MeterStyle1]
FontFace=ArcadeClassic
FontSize=22
FontColor=255,255,255,220
AntiAlias=1

[MeterStyle2]

FontFace=Verdana
FontSize=9
FontColor=255,255,255


;--------------------------------------------
;--------------------------------------------
;--------------------------------------------
; Measures
;--------------------------------------------
;--------------------------------------------
;--------------------------------------------


[MeasureUsedDiskG]

Measure=FreeDiskSpace
Drive=G:
InvertMeasure=1
;UpdateDivider=900


[MeasureTotalDiskG]
Measure=FreeDiskSpace
Drive=G:
Total=1
;UpdateDivider=900

[MeasureUsedDiskG%]

Measure=Calc
Formula=(100*MeasureUsedDiskG/MeasureTotalDiskG)

IfCondition=(MeasureUsedDiskG%<=40)
IfTrueAction=[!SetOption MeterG:AsemanUsedRoundMeter LineColor "255,0,0,255"][!UpdateMeter MeterG:AsemanUsedRoundMeter][!Redraw]
IfCondition2=((MeasureUsedDiskG%>40)&&(MeasureUsedDiskG%<80))
IfTrueAction2=[!SetOption MeterG:AsemanUsedRoundMeter Linecolor "0,255,0,255"][!UpdateMeter MeterG:AsemanUsedRoundMeter][!Redraw]
IfCondition3=(MeasureUsedDiskG%>=80)
IfTrueAction3=[!SetOption MeterG:AsemanUsedRoundMeter LineColor "0,0,255,255"][!UpdateMeter MeterG:AsemanUsedRoundMeter][!Redraw]

[MeasureFreeDiskG]

Measure=FreeDiskSpace
Drive=G:
UpdateDivider=900

[MeasureDiskGLabel]
Measure=FreeDiskSpace
Drive=G:
Label=1
UpdateDivider=-1


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


[MeterBackground]

Meter=IMAGE
ImageName=#SKINSPATH#\CommandCenter\HardDrives\HardDrivesErikseen\HardDrivesErikseenPohja1.0.png

X=0
Y=0
W=275
H=135

[MeterHardDrivesOtsikko]

Meter=String
MeterStyle=MeterStyle1

MeasureName=MeasureDiskGLabel

X=([MeterBackground:W]/2)
Y=2
W=0
H=15

StringAlign=Center
StringEffect=Border

Text=G: %1
Antialias=1

[MeterG:AsemanTotalRoundMeter]

Meter=Roundline
MeasureName=MeasureTotalDiskG

X=50
Y=85
W=0
H=0

StartAngle=4.712
RotationAngle=6.283
LineLength=30
LineColor=255,255,255,0
Solid=1
AntiAlias=1

[MeterG:AsemanUsedRoundMeter]

Meter=Roundline
MeasureName=MeasureUsedDiskG%

X=50
Y=([MeterG:AsemanTotalRoundMeter:Y])
W=0
H=0

StartAngle=(Rad(270))
RotationAngle=(Rad(360))
LineStart=20
LineLength=30
;Percentual=1
;LineColor=100,100,255,255

Solid=1
AntiAlias=1


[MeterG:AsemanFreeRoundMeter]

Meter=Roundline
MeasureName=MeasureFreeDiskG

X=50
Y=([MeterG:AsemanTotalRoundMeter:Y])
W=0
H=0

StartAngle=4.712
RotationAngle=-6.283
LineStart=20
LineLength=30
LineColor=0,150,200,255
Solid=1
AntiAlias=1


[MeterG:AsemanPointer]

Meter=Roundline
MeasureName=MeasureUsedDiskG

X=50
Y=([MeterG:AsemanTotalRoundMeter:Y])
W=0
H=0

StartAngle=(Rad(270))
RotationAngle=(Rad(360))
LineWidth=5
LineStart=20
LineLength=30
LineColor=217,54,54,255
AntiAlias=1


[MeterG:AsemanTeksti]
Meter=String
MeterStyle=MeterStyle2


X=50
Y=85
W=0
H=0

FontColor=#Color2#
StringAlign=CenterCenter
AntiAlias=1
Text=G:
AutoScale=1


[MeterG:AsemanUsed]
Meter=String
MeterStyle=Meterstyle2

MeasureName=MeasureUsedDiskG

X=([MeterG:AsemanTotalRoundMeter:X]+35)
Y=([MeterG:AsemanTotalRoundMeter:Y]-15)
W=110
H=15

FontColor=#Color2#
AntiAlias=1
StringAlign=LeftBottom
;Percentual=1
Text=Used: %1B
AutoScale=1


[MeterG:AsemanUsed%]
Meter=String
MeterStyle=Meterstyle2

MeasureName=MeasureUsedDiskG

X=([MeterG:AsemanUsed:X]+[MeterG:AsemanUsed:W])
Y=([MeterG:AsemanTotalRoundMeter:Y]-15)
W=0
H=0

FontColor=#Color2#
AntiAlias=1
Percentual=1
StringAlign=LeftBottom
Text=(%1%)
AutoScale=1


[MeterG:AsemanFree]
Meter=String
MeterStyle=MeterStyle2

MeasureName=MeasureFreeDiskG

X=([MeterG:AsemanTotalRoundMeter:X]+35)
Y=5R
W=110
H=0

FontColor=#Color2#
AntiAlias=1
;Percentual=1
Text=Free: %1B
AutoScale=1


[MeterG:AsemanFree%]
Meter=String
MeterStyle=MeterStyle2

MeasureName=MeasureFreeDiskG

X=([MeterG:AsemanFree:X]+[MeterG:AsemanFree:W])
Y=([MeterG:AsemanFree:Y])
W=0
H=15

FontColor=#Color2#
AntiAlias=1
Percentual=1
StringAlign=Left
Text=(%1%)
AutoScale=1


[MeterG:Asemankäyttö]
Meter=String
MeterStyle=MeterStyle2

MeasureName=MeasureTotalDiskG
MeasureName2=MeasureUsedDiskG

X=([MeterG:AsemanTotalRoundMeter:X]+35)
Y=5R
W=0
H=15

FontColor=#Color2#
AntiAlias=1
Text=Total: %2B / %1B
AutoScale=1

I tried to make that code look a little cleaner that it was at the beginning. This on is like my test skin file to get everything to work first before i make the final version.

I just really doesn't find the problem. I havent used formulas before so i think problem lies somewhere on that [MeasureUsedDiskG%] or [MeterG:AsemanUsedRoundMeter]. Can someone tell me where the problem lies or am I doing this wrong way?

Ps. Im from finland so those names can be confusing, but that shouldn't make any difference otherwise.

Thanks for everyone willing to help :) Ask if you need more information.
Attachments
example.JPG
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5381
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Hard drive roundline meter color change

Post by eclectic-tech »

Avoid using special characters in your section names. :17denial

The log shows an 'extra operation' error in the IfCondition tests, because you have the modulo symbol % in the section name; [MeasureUsedDiskG%]...

The % symbol is recognized as a mathematical operation by rainmeter and is causing the errors in your skin.

Rename that section and modify the IfCondition statements and it should work.
Attachments
formulasyntax.png
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Hard drive roundline meter color change

Post by jsmorley »

Exactly...

https://docs.rainmeter.net/manual/skins/#Format
There are only a few rules about using the INI format:

All section names in a skin must be unique.
All option names within a section must be unique.
Section and option names should include alphanumeric characters only (no spaces or punctuation).
Option values may be contained by quotes ("). If so, Rainmeter will ignore the containing quotes.
Option values must be kept on a single line.
Using spaces, punctuation or characters other than a-zA-Z0-9 in [SectionNames] is not forbidden, but it does offer an opportunity to scratch your head later when it causes problems...
JusMu
Posts: 2
Joined: February 21st, 2018, 11:59 am

Re: Hard drive roundline meter color change

Post by JusMu »

O.O ouch... feel like i trolled myself... so obvious.

Well that happens me pretty much that i'm "blind" when reading my own text. Well that solved the problem. I had feeling it shouldn't be nothing too big. I think i just started copypaste on something and it did get in there.


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

Re: Hard drive roundline meter color change

Post by balala »

jsmorley wrote:Using spaces, punctuation or characters other than a-zA-Z0-9 in [SectionNames] is not forbidden, but it does offer an opportunity to scratch your head later when it causes problems...
But not this is the issue. Even if I replaced the G: in measure/meter names, the IfConditions still are not working. The only way I could make it to work was to use the measure name in the IfCondition options as section variables and add the DynamicVariables=1 option to the [MeasureUsedDiskG%] measure. The IfConditions of the original measure are not working:

Code: Select all

[MeasureUsedDiskG%]
Measure=Calc
Formula=(100*MeasureUsedDiskG/MeasureTotalDiskG)
IfCondition=(MeasureUsedDiskG%<=40)
IfTrueAction=[!SetOption MeterGAsemanUsedRoundMeter LineColor "255,0,0,255"][!UpdateMeter MeterGAsemanUsedRoundMeter][!Redraw]
IfCondition2=((MeasureUsedDiskG%>40)&&(MeasureUsedDiskG%<80))
IfTrueAction2=[!SetOption MeterGAsemanUsedRoundMeter Linecolor "0,255,0,255"][!UpdateMeter MeterGAsemanUsedRoundMeter][!Redraw]
IfCondition3=(MeasureUsedDiskG%>=80)
IfTrueAction3=[!SetOption MeterGAsemanUsedRoundMeter LineColor "0,0,255,255"][!UpdateMeter MeterGAsemanUsedRoundMeter][!Redraw]
But with the following modifications, they are working 100%:

Code: Select all

[MeasureUsedDiskG%]
Measure=Calc
Formula=(100*MeasureUsedDiskG/MeasureTotalDiskG)
IfCondition=([MeasureUsedDiskG%]<=40)
IfTrueAction=[!SetOption MeterGAsemanUsedRoundMeter LineColor "255,0,0,255"][!UpdateMeter MeterGAsemanUsedRoundMeter][!Redraw]
IfCondition2=(([MeasureUsedDiskG%]>40)&&([MeasureUsedDiskG%]<80))
IfTrueAction2=[!SetOption MeterGAsemanUsedRoundMeter Linecolor "0,255,0,255"][!UpdateMeter MeterGAsemanUsedRoundMeter][!Redraw]
IfCondition3=([MeasureUsedDiskG%]>=80)
IfTrueAction3=[!SetOption MeterGAsemanUsedRoundMeter LineColor "0,0,255,255"][!UpdateMeter MeterGAsemanUsedRoundMeter][!Redraw]
DynamicVariables=1
However I can't explain why. So, why, if anyone knows?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Hard drive roundline meter color change

Post by jsmorley »

It's because IfCondition=(MeasureUsedDiskG%<=40) causes an invalid formula error due to the % modulus operator in the formula. When you use it as a [SectionVariable], that isolates the % character from the formula, and makes it unambiguous that it is a part of the [SectionName], and not a mathematical operator.

So the root cause is still the same...
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hard drive roundline meter color change

Post by balala »

jsmorley wrote:It's because IfCondition=(MeasureUsedDiskG%<=40) causes an invalid formula error due to the % modulus operator in the formula. When you use it as a [SectionVariable], that isolates the % character from the formula, and makes it unambiguous that it is a part of the [SectionName], and not a mathematical operator.

So the root cause is still the same...
Oh, I see now. I didn't think to this. But you're right.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Hard drive roundline meter color change

Post by jsmorley »

balala wrote:Oh, I see now. I didn't think to this. But you're right.
Using a percent sign in a [SectionName] is not at all uncommon, you will often see [FreeSpace%] and such. In almost all cases, that is perfectly fine. I do it myself. It is really only two places, in the Formula option in a Calc measure, and in the test in an IfCondition, where it is going to cause problems due to there just being no way for Rainmeter to know if the % is part of the name or the formula. Everywhere else in Rainmeter, it will either ALWAYS be used in brackets as a [SectionVariable] or in a meter option like MeasureName=SomeMeasure where a formula is just not allowed or considered.

It is however why we recommend against using characters other than a-zA-Z0-9 in section names. It can bite you when you least expect it, and it can be hard to figure out why.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hard drive roundline meter color change

Post by balala »

jsmorley wrote:Using a percent sign in a [SectionName] is not at all uncommon, you will often see [FreeSpace%] and such. In almost all cases, that is perfectly fine. I do it myself. It is really only two places, in the Formula option in a Calc measure, and in the test in an IfCondition, where it is going to cause problems due to there just being no way for Rainmeter to know if the % is part of the name or the formula. Everywhere else in Rainmeter, it will either ALWAYS be used in brackets as a [SectionVariable] or in a meter option like MeasureName=SomeMeasure where a formula is just not allowed or considered.

It is however why we recommend against using characters other than a-zA-Z0-9 in section names. It can bite you when you least expect it, and it can be hard to figure out why.
Thanks for the details. Now thinking better, everything is clear and normal.
Post Reply