It is currently May 19th, 2024, 6:09 pm

Assigning a number to any named meter or measure!

Tips and Tricks from the Rainmeter Community
User avatar
Cariboudjan
Posts: 268
Joined: May 12th, 2019, 8:55 am

Assigning a number to any named meter or measure!

Post by Cariboudjan »

When making a new skin, it can be helpful to assign a number to each of your meters so that they can easily reference other meters, such as a string's icon, when performing Mouse Actions, like MouseOverAction or LeftMouseUpAction. This allows you to control the effect of multiple meters with the action of a single meter, without having to repeat code over and over again.

In the below example, we use [##CURRENTSECTION#]. This is a nested variable. What are are doing with [##CURRENTSECTION#] is looking for a variable of the same name as the section name of the meter your cursor is hovering over.

By creating variables called String1, String2, String3, etc. and giving them values 1, 2, 3, etc. we are applying a value that can be referenced by a section name. Then using [##CURRENTSECTION#] in a style, String1, String2, String3, can easily control Icon1, Icon2, Icon3, etc. (or vice versa)

You may see some skins have sections named [1], [2], [3], etc. and using #CURRENTSECTION# to reference their related meters. This method works in simple projects, but more complicated projects may want to apply this method instead.

In the below example, MouseOverAction for the strings will set the squares to the same color as the strings, and MouseOverAction for the icons will set the strings to the same color as the icons. By using the [1], [2], [3] section name method you would not be able to perform this using styles alone.

666434354.gif

Code: Select all

[Rainmeter]
MiddleMouseDownAction=[!Refresh]

[Variables]
MeterValue=0

String1=1
String2=2
String3=3
String4=4
String5=5
String6=6

Icon1=1
Icon2=2
Icon3=3
Icon4=4
Icon5=5
Icon6=6

String1Text=One
String2Text=Two
String3Text=Three
String4Text=Four
String5Text=Five
String6Text=Six

String1Color=255,255,255
String2Color=200,200,200
String3Color=155,155,155
String4Color=100,100,100
String5Color=55,55,55
String6Color=0,0,0

Icon1Color=255,0,0
Icon2Color=0,255,0
Icon3Color=0,0,255
Icon4Color=255,0,255
Icon5Color=0,255,255
Icon6Color=255,255,0

;-----------------------------------

[StringStyle]
SolidColor=0,0,0
Text=[##CURRENTSECTION#Text]
FontColor=[##CURRENTSECTION#Color]
FontSize=15
MouseOverAction=[!SetVariable MeterValue [##CURRENTSECTION#]][!SetOption Icon[##CURRENTSECTION#] SolidColor "[##CURRENTSECTION#Color]"][!UpdateMeter Icon[##CURRENTSECTION#]][!Redraw]
MouseLeaveAction=[!SetOption Icon[##CURRENTSECTION#] SolidColor ""][!UpdateMeter Icon[##CURRENTSECTION#]][!Redraw]
Padding=25,0,0,0
W=100
H=25
Y=5R

[IconStyle]
SolidColor=[##CURRENTSECTION#Color]
MouseOverAction=[!SetVariable MeterValue [##CURRENTSECTION#]][!SetOption String[##CURRENTSECTION#] FontColor "[##CURRENTSECTION#Color]"][!UpdateMeter String[##CURRENTSECTION#]][!Redraw]
MouseLeaveAction=[!SetOption String[##CURRENTSECTION#] FontColor ""][!UpdateMeter String[##CURRENTSECTION#]][!Redraw]
W=25
H=25
Y=5R

;-----------------------------------

[String1]
Meter=String
MeterStyle=StringStyle
Y=0

[String2]
Meter=String
MeterStyle=StringStyle

[String3]
Meter=String
MeterStyle=StringStyle

[String4]
Meter=String
MeterStyle=StringStyle

[String5]
Meter=String
MeterStyle=StringStyle

[String6]
Meter=String
MeterStyle=StringStyle

;-----------------------------------

[Icon1]
Meter=Image
MeterStyle=IconStyle
Y=0

[Icon2]
Meter=Image
MeterStyle=IconStyle

[Icon3]
Meter=Image
MeterStyle=IconStyle

[Icon4]
Meter=Image
MeterStyle=IconStyle

[Icon5]
Meter=Image
MeterStyle=IconStyle

[Icon6]
Meter=Image
MeterStyle=IconStyle
You do not have the required permissions to view the files attached to this post.