It is currently April 24th, 2024, 10:04 pm

Making a counter.

Get help with creating, editing & fixing problems with skins
ItsJustRyan
Posts: 81
Joined: October 25th, 2019, 1:20 am

Making a counter.

Post by ItsJustRyan »

Hi!

I'm trying to make a "counter" thing, where if i press the up arrow it increases the number for the corresponding number and vice versa for the down arrow. How can I fix this? I put my first method at the bottom.

Code: Select all

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

[Variables]
countera = 0
counterb = 0

[ClickCounter]
Measure=Calc
Formula=countera = countera+1
Disabled=1
UpdateDivider=-1

[ClickCounterdown]
Measure=Calc
Formula=countera=countera-1
Disabled=1
UpdateDivider=-1

[ClickCounteralt]
Measure=Calc
Formula=counterb=counterb+1
Disabled=1
UpdateDivider=-1

[ClickCounteraltdown]
Measure=Calc
Formula=counterb=counterb-1
Disabled=1
UpdateDivider=-1

[Background]
 Meter=Shape
 Shape=Rectangle 0,0,63,70 | StrokeWidth 0 | FIllColor 255,255,255,255 | Stroke Color 255,255,255,255

[ShowClicks]
Meter=String
MeasureName=countera
X=10
Y=19
FontColor=255,165,0
FontFace=Segoe UI
FontSize=15
SolidColor=255,255,255,255
AntiAlias=1
Text=%1
LeftMouseUpAction=[!EnableMeasure ClickCounter][!UpdateMeasure ClickCounter][!UpdateMeter ShowClicks][!Redraw]

[ShowClicksalt]
Meter=String
MeasureName=counterb
X=40
Y=19
FontColor=255,165,0
FontFace=Segoe UI
FontSize=15
SolidColor=255,255,255,255
AntiAlias=1
Text=%1
LeftMouseUpAction=[!EnableMeasure ClickCounteralt][!UpdateMeasure ClickCounteralt][!UpdateMeter ShowClicksalt][!Redraw]

[MeterUp]
Meter=Image
ImageName=#@#Arrow_C.png
X=6
Y=4
W=20
Preserveaspectratio=1
AntiAlias=1
ImageTint=255,165,0
SolidColor=0,0,0,1
LeftMouseUpAction=[!EnableMeasure ClickCounter][!UpdateMeasure ClickCounter][!UpdateMeter ShowClicks][!Redraw]

[MeterUpalt]
Meter=Image
ImageName=#@#Arrow_C.png
X=36
Y=4
W=20
Preserveaspectratio=1
AntiAlias=1
ImageTint=255,165,0
SolidColor=0,0,0,1
LeftMouseUpAction=[!EnableMeasure ClickCounteralt][!UpdateMeasure ClickCounteralt][!UpdateMeter ShowClicksalt][!Redraw]

[MeterDown]
Meter=Image
ImageName=#@#image.png
MaskImageFlip=Horizontal
X=6
Y=45
W=20
Preserveaspectratio=1
AntiAlias=1
ImageTint=255,165,0
SolidColor=0,0,0,1
LeftMouseUpAction=[!EnableMeasure ClickCounterdown][!UpdateMeasure ClickCounterdown][!UpdateMeter ShowClicks][!Redraw]

[Meterdownalt]
Meter=Image
ImageName=#@#image.png
MaskImageFlip=Horizontal
X=36
Y=45
W=20
Preserveaspectratio=1
AntiAlias=1
ImageTint=255,165,0
SolidColor=0,0,0,1
LeftMouseUpAction=[!EnableMeasure ClickCounteraltdown][!UpdateMeasure ClickCounteraltdown][!UpdateMeter ShowClicksalt][!Redraw]
Before this one I tried another method which worked going upwards but not downwards.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
counter1=0
counter2=0

[ClickCounter]
Measure=Calc
Formula=ClickCounter+1
Disabled=1
UpdateDivider=-1

[ClickCounterdown]
Measure=Calc
Formula=ClickCounter-1
Disabled=1
UpdateDivider=-1

[ClickCounteralt]
Measure=Calc
Formula=ClickCounteralt+1
Disabled=1
UpdateDivider=-1

[ClickCounteraltdown]
Measure=Calc
Formula=ClickCounteralt-1
Disabled=1
UpdateDivider=-1

[Background]
 Meter=Shape
 Shape=Rectangle 0,0,63,70 | StrokeWidth 0 | FIllColor 255,255,255,255 | Stroke Color 255,255,255,255

[ShowClicks]
Meter=String
MeasureName=ClickCounter
X=10
Y=19
FontColor=255,165,0
FontFace=Segoe UI
FontSize=15
SolidColor=255,255,255,255
AntiAlias=1
Text=%1
LeftMouseUpAction=[!EnableMeasure ClickCounter][!UpdateMeasure ClickCounter][!UpdateMeter ShowClicks][!Redraw]

[ShowClicksalt]
Meter=String
MeasureName=ClickCounteralt
X=40
Y=19
FontColor=255,165,0
FontFace=Segoe UI
FontSize=15
SolidColor=255,255,255,255
AntiAlias=1
Text=%1
LeftMouseUpAction=[!EnableMeasure ClickCounteralt][!UpdateMeasure ClickCounteralt][!UpdateMeter ShowClicksalt][!Redraw]

[MeterUp]
Meter=Image
ImageName=#@#Arrow_C.png
X=6
Y=4
W=20
Preserveaspectratio=1
AntiAlias=1
ImageTint=255,165,0
SolidColor=0,0,0,1
LeftMouseUpAction=[!EnableMeasure ClickCounter][!UpdateMeasure ClickCounter][!UpdateMeter ShowClicks][!Redraw]

[MeterUpalt]
Meter=Image
ImageName=#@#Arrow_C.png
X=36
Y=4
W=20
Preserveaspectratio=1
AntiAlias=1
ImageTint=255,165,0
SolidColor=0,0,0,1
LeftMouseUpAction=[!EnableMeasure ClickCounteralt][!UpdateMeasure ClickCounteralt][!UpdateMeter ShowClicksalt][!Redraw]

[MeterDown]
Meter=Image
ImageName=#@#image.png
MaskImageFlip=Horizontal
X=6
Y=45
W=20
Preserveaspectratio=1
AntiAlias=1
ImageTint=255,165,0
SolidColor=0,0,0,1
LeftMouseUpAction=[!EnableMeasure ClickCounterdown][!UpdateMeasure ClickCounterdown][!UpdateMeter ShowClicks][!Redraw]

[Meterdownalt]
Meter=Image
ImageName=#@#image.png
MaskImageFlip=Horizontal
X=36
Y=45
W=20
Preserveaspectratio=1
AntiAlias=1
ImageTint=255,165,0
SolidColor=0,0,0,1
LeftMouseUpAction=[!EnableMeasure ClickCounteraltdown][!UpdateMeasure ClickCounteraltdown][!UpdateMeter ShowClicksalt][!Redraw]
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Making a counter.

Post by rbriddickk84 »

Hey there! :)

I made a slight modification to your code, also since i don't have the image files, i modified them as simple solid colors.
I commented out your code-parts which are referenced to your images.

Here is the new code:

Code: Select all

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

[Variables]
countera=0
counterb=0
fresh=[!UpdateMeasureGroup cc][!UpdateMeterGroup ui][!Redraw]

[Equalizer]
Measure=Calc
IfCondition=#countera#<0
IfTrueAction=[!SetVariable countera 0][!UpdateMeasureGroup cc][!UpdateMeterGroup ui][!Redraw]
IfCondition2=#counterb#<0
IfTrueAction2=[!SetVariable counterb 0][!UpdateMeasureGroup cc][!UpdateMeterGroup ui][!Redraw]
UpdateDivider=-1
DynamicVariables=1
Group=cc

[Background]
Meter=Shape
Shape=Rectangle 0,0,63,70 | StrokeWidth 0 | FIllColor 255,255,255,255 | Stroke Color 255,255,255,255

[ShowClicks]
Meter=String
X=10
Y=19
FontColor=255,165,0
FontFace=Segoe UI
FontSize=15
SolidColor=255,255,255,255
AntiAlias=1
Text=#countera#
UpdateDivider=-1
DynamicVariables=1
Group=ui

[ShowClicksalt]
Meter=String
X=40
Y=19
FontColor=255,165,0
FontFace=Segoe UI
FontSize=15
SolidColor=255,255,255,255
AntiAlias=1
Text=#counterb#
UpdateDivider=-1
DynamicVariables=1
Group=ui

[MeterUp]
Meter=Image
;ImageName=#@#Arrow_C.png
;SolidColor=0,0,0,1
SolidColor=250,250,0
X=6
Y=4
W=20
H=20
Preserveaspectratio=1
AntiAlias=1
;ImageTint=255,165,0
LeftMouseUpAction=[!SetVariable countera "(#countera#+1)"]#fresh#
UpdateDivider=-1
DynamicVariables=1
Group=ui

[MeterUpalt]
Meter=Image
;ImageName=#@#Arrow_C.png
;SolidColor=0,0,0,1
SolidColor=250,0,0
X=36
Y=4
W=20
H=20
Preserveaspectratio=1
AntiAlias=1
;ImageTint=255,165,0
LeftMouseUpAction=[!SetVariable counterb "(#counterb#+1)"]#fresh#
UpdateDivider=-1
DynamicVariables=1
Group=ui

[MeterDown]
Meter=Image
;ImageName=#@#image.png
;MaskImageFlip=Horizontal
;ImageTint=255,165,0
;SolidColor=0,0,0,1
SolidColor=250,0,250
X=6
Y=45
W=20
H=20
Preserveaspectratio=1
AntiAlias=1
LeftMouseUpAction=[!SetVariable countera "(#countera#-1)"]#fresh#
UpdateDivider=-1
DynamicVariables=1
Group=ui

[Meterdownalt]
Meter=Image
;ImageName=#@#image.png
;MaskImageFlip=Horizontal
;ImageTint=255,165,0
;SolidColor=0,0,0,1
SolidColor=10,40,110
X=36
Y=45
W=20
H=20
Preserveaspectratio=1
AntiAlias=1
LeftMouseUpAction=[!SetVariable counterb "(#counterb#-1)"]#fresh#
UpdateDivider=-1
DynamicVariables=1
Group=ui
What i did was i just simply used one counter measure, which only monitoring the "countera" and "counterb" variables to not go down in negative.
If you intended to go down in negative way as well, you can just simply delete that "Equalizer" measure.
All other counting is happening from LeftMouseClicks commands. If you click on the corresponding image, it will directly set your "countera" and "counterb" VARIABLES as intended and the number displays are dynamically feeding back the modified values. You don't have to click on the numbers to update them.
In your code you were refer to countera and counterb as measures, but they are just variables, the Rainmeter Log is displaying that too!

I don't know if you want your skin to remember the modified numbers, but if you do then you have to write the variables as well into an external txt file.

If this was any help, or you need any more clearence, just ask! ;)
ItsJustRyan
Posts: 81
Joined: October 25th, 2019, 1:20 am

Re: Making a counter.

Post by ItsJustRyan »

Hi!

Thanks for the help! I've now also added a reset function to individually reset the counters. I'll attach the code if anyone ever needs it for some reason.

Another question I have is how do I set it up so that I can press a button (probably on another skin) to toggle in on/off (or hidden/shown).

Code: Select all

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

[Variables]
countera=0
counterb=0
fresh=[!UpdateMeasureGroup cc][!UpdateMeterGroup ui][!Redraw]

[Equalizer]
Measure=Calc
IfCondition=#countera#<0
IfTrueAction=[!SetVariable countera 0][!UpdateMeasureGroup cc][!UpdateMeterGroup ui][!Redraw]
IfCondition2=#counterb#<0
IfTrueAction2=[!SetVariable counterb 0][!UpdateMeasureGroup cc][!UpdateMeterGroup ui][!Redraw]
UpdateDivider=-1
DynamicVariables=1
Group=cc

[Background]
Meter=Shape
Shape=Rectangle 35,31,63,70 | StrokeWidth 0 | FIllColor 255,255,255,255 | Stroke Color 255,255,255,255

[ShowClicks]
Meter=String
X=45
Y=(19+31)
FontColor=255,165,0
FontFace=Segoe UI
FontSize=15
SolidColor=255,255,255,255
AntiAlias=1
Text=#countera#
UpdateDivider=-1
DynamicVariables=1
Group=ui

[ShowClicksalt]
Meter=String
X=75
Y=(19+31)
FontColor=255,165,0
FontFace=Segoe UI
FontSize=15
SolidColor=255,255,255,255
AntiAlias=1
Text=#counterb#
UpdateDivider=-1
DynamicVariables=1
Group=ui

[MeterUp]
Meter=Image
ImageName=#@#Arrow_C.png
X=41
Y=(4+31)
W=20
H=20
Preserveaspectratio=1
AntiAlias=1
ImageTint=255,165,0
LeftMouseUpAction=[!SetVariable countera "(#countera#+1)"]#fresh#
UpdateDivider=-1
DynamicVariables=1
Group=ui

[MeterUpalt]
Meter=Image
ImageName=#@#Arrow_C.png
X=71
Y=(4+31)
W=20
H=20
Preserveaspectratio=1
AntiAlias=1
ImageTint=255,165,0
LeftMouseUpAction=[!SetVariable counterb "(#counterb#+1)"]#fresh#
UpdateDivider=-1
DynamicVariables=1
Group=ui

[MeterDown]
Meter=Image
ImageName=#@#image.png
MaskImageFlip=Horizontal
ImageTint=255,165,0
X=41
Y=(45+31)
W=20
H=20
Preserveaspectratio=1
AntiAlias=1
LeftMouseUpAction=[!SetVariable countera "(#countera#-1)"]#fresh#
UpdateDivider=-1
DynamicVariables=1
Group=ui

[Meterdownalt]
Meter=Image
ImageName=#@#image.png
MaskImageFlip=Horizontal
ImageTint=255,165,0
X=71
Y=(45+31)
W=20
H=20
Preserveaspectratio=1
AntiAlias=1
LeftMouseUpAction=[!SetVariable counterb "(#counterb#-1)"]#fresh#
UpdateDivider=-1
DynamicVariables=1
Group=ui

[TriangleTop]
Meter=Image
ImageName=#@#Images/1.png
w=63
h=31
x=35
Imagetint=255,165,0
LeftMouseUpAction=[!SetVariable countera "0"]#fresh#

[TriangleBottom]
Meter=Image
ImageName=#@#Images/3.png
w=63
h=31
y=101
x=35
Imagetint=255,165,0
LeftMouseUpAction=[!SetVariable counterb "0"]#fresh#
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Making a counter.

Post by balala »

ItsJustRyan wrote: October 27th, 2020, 2:17 pm Another question I have is how do I set it up so that I can press a button (probably on another skin) to toggle in on/off (or hidden/shown).
Not completely clear: would zou like to hide / show this skin through another skin? If so, there is another question as well: would you like to just hide / show the skin or to completely deactivate / activate it (close / relaunch)?
In any case you have to use either the !Toggle(Fade) (if you want to hide / show the skin), or the !ToggleConfig (if you want to close / load the skin) bang. If you're using the !Toggle(Fade) bang, make sure to add the Config parameter. For instance if the skin with the above code is C:\Users\YourName\Documents\Rainmeter\Skins\MyConfig\MySkin.ini, you have to add the following bang to the meter which has to toggle this skin: [!ToggleFade "MyConfig"]. Note that onlz the config is used in this bang, not the name of the .ini file as well.
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Making a counter.

Post by rbriddickk84 »

ItsJustRyan wrote: October 27th, 2020, 2:17 pm Hi!

Thanks for the help! I've now also added a reset function to individually reset the counters. I'll attach the code if anyone ever needs it for some reason.

Hey! :)

You are welcome, happy if it worked! :)
I was wondering about if you use !SetVariable command, if you ever need the "" marks for the value, like [!SetVariable somevar "0"], or just [!SetVariable somevar 0]...

I know it's not a big deal, just always wondered about that syntax.

For the last part is also not clear what you would like to achieve.
ItsJustRyan
Posts: 81
Joined: October 25th, 2019, 1:20 am

Re: Making a counter.

Post by ItsJustRyan »

rbriddickk84 wrote: October 27th, 2020, 8:14 pm For the last part is also not clear what you would like to achieve.
That was just a decorational thing lol.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Making a counter.

Post by jsmorley »

rbriddickk84 wrote: October 27th, 2020, 8:14 pm I was wondering about if you use !SetVariable command, if you ever need the "" marks for the value, like [!SetVariable somevar "0"], or just [!SetVariable somevar 0]...

I know it's not a big deal, just always wondered about that syntax.
The way the "quotes" work in a !Bang is that they are used to avoid confusion with spaces in the values. Since the parameters of a !Bang are separated and delineated by spaces, Rainmeter just can't reliably parse the !Bang if the values have spaces in them. The "quotes" are used to resolve this issue, by allowing you to make it clear what is a space in a value, and what is a space to delineate a parameter.

So the long and the short of it is that you don't need "quotes" if the value of a parameter doesn't have spaces in it. You DO if the value of a parameter does, or might, have spaces in it.

Since the value of a parameter can often be a #Variable# or a [SectionVariable], and that makes it harder to be SURE that it won't have spaces in it, it is, and has always been, my recommendation that you always enclose all value parameters in a !Bang in quotes. Having them there when you don't strictly need them can never hurt, but not having them when you do can and will cause problems.

I would personally use [!SetVariable somevar "0"] since I find it easier to just get into the habit of using the "quotes" on value parameters, and then I don't even have to think about what the actual value is, or might be...

I don't want to make too big a deal out of this "habit" however, as I fully understand that it can be counter-intuitive to enclose a number value in a situation where the !Bang is driving a number-based result in "quotes". That sorta feels like you are somehow telling Rainmeter that the value is a string, but you aren't. The quotes are just to delineate the parameter in an unambiguous way. So if you want to modify the "habit" to always enclose text values in "quotes", but always leave the "quotes" off on purely numeric values, that's fine as well.
ItsJustRyan
Posts: 81
Joined: October 25th, 2019, 1:20 am

Re: Making a counter.

Post by ItsJustRyan »

balala wrote: October 27th, 2020, 3:08 pm Not completely clear: would zou like to hide / show this skin through another skin? If so, there is another question as well: would you like to just hide / show the skin or to completely deactivate / activate it (close / relaunch)?
In any case you have to use either the !Toggle(Fade) (if you want to hide / show the skin), or the !ToggleConfig (if you want to close / load the skin) bang. If you're using the !Toggle(Fade) bang, make sure to add the Config parameter. For instance if the skin with the above code is C:\Users\YourName\Documents\Rainmeter\Skins\MyConfig\MySkin.ini, you have to add the following bang to the meter which has to toggle this skin: [!ToggleFade "MyConfig"]. Note that onlz the config is used in this bang, not the name of the .ini file as well.
Thanks! It worked.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Making a counter.

Post by balala »

ItsJustRyan wrote: November 6th, 2020, 1:03 pm Thanks! It worked.
Ok, I'm glad. :great:
alexandroid
Posts: 2
Joined: November 7th, 2020, 6:43 am

Re: Making a counter.

Post by alexandroid »

This discussion was helpful to me. I'm trying to make a counter based on the code suggested above and I want to add function "when the counter number changes, the color of round decoration element changes too". But the color doesn't change. Please help me find the error. Here is my code:

Code: Select all

[Variables]
counter_a=0
RoundColorX=255,255,255,33

[Equalizer]
Measure=Calc
IfCondition=(#counter_a#<0)||(#counter_a#>2)
IfTrueAction=[!SetVariable counter_a 0][!UpdateMeasureGroup cc][!UpdateMeterGroup ui][!Redraw]
UpdateDivider=-1
DynamicVariables=1
Group=cc

[ColorMod]
Measure=String
IfCondition=(#counter_a#=1)
IfTrueAction=[!SetVariable RoundColorX "255,217,62,33"][!UpdateMeasureGroup cc][!UpdateMeterGroup ui][!Redraw]
IfCondition2=(#counter_a#=2)
IfTrueAction2=[!SetVariable RoundColorX "240,44,18,33"][!UpdateMeasureGroup cc][!UpdateMeterGroup ui][!Redraw]
UpdateDivider=-1
DynamicVariables=1
Group=ui

[MeterDown]
Meter=Image
SolidColor=40,80,110
X=0
Y=6
W=102
H=80
AntiAlias=1
LeftMouseUpAction=[!SetVariable counter_a "(#counter_a#-1)"][!UpdateMeasureGroup cc][!UpdateMeterGroup ui][!Redraw]
UpdateDivider=-1
DynamicVariables=1
Group=ui

[MeterUp]
Meter=Image
SolidColor=40,80,110
X=108
Y=6
W=192
H=80
LeftMouseUpAction=[!SetVariable counter_a "(#counter_a#+1)"][!UpdateMeasureGroup cc][!UpdateMeterGroup ui][!Redraw]
UpdateDivider=-1
DynamicVariables=1
AntiAlias=1
Group=ui

[ShowColorRound]
Meter=Roundline
X=112
Y=3
W=86
H=86
LineLength=43
LineColor=#RoundColorX#
Solid=1
AntiAlias=1
Group=ui

[ShowClicks]
Meter=String
X=138
Y=0
FontColor=255,165,0,255
FontFace=Segoe UI
FontSize=48
AntiAlias=1
Text=#counter_a#
UpdateDivider=-1
DynamicVariables=1
Group=ui