It is currently January 22nd, 2021, 3:43 pm

[Solved] Is it possible to make a "Click Counter"?

Help with creating, editing & fixing problems with skins
User avatar
Krainz
Posts: 186
Joined: May 27th, 2012, 5:16 am

[Solved] Is it possible to make a "Click Counter"?

Post by Krainz »

When you click a meter, it raises the click counter by one and you have a text showing how much you have clicked.

Code: Select all

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

[Variables]
Test=[Calc]
Clicks=[Clickcounter]

[Calc]
Measure=Calc
Formula=5 + 50

[Clickcounter]
Measure=Calc
Formula=cCounter+1
Disabled=1

[Meter]
Meter=Image
X=0
Y=1
H=50
W=50
Solidcolor=0,0,255,255
DynamicVariables=1

[ShowClicks]
Meter=String
X=#Test#
Y=0
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=17
StringEffect=Shadow
FontEffectColor=0,0,0,255
AntiAlias=1
Text=#Clicks#
LeftMouseDownAction=[!EnableMeasure Clickcounter]


My problems:

The text isn't showing properly how many clicks (it stays at 0)

How do I make the measure pause at one click, and then reactivate only on the next (so the number shown will be the exact amount of clicks)?

EDIT:

NVM, just found one http://www.reddit.com/r/Rainmeter/comments/2jos8c/does_anyone_know_of_a_tallyclick_counter/cldph8u
User avatar
jsmorley
Developer
Posts: 21466
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Is it possible to make a "Click Counter"?

Post by jsmorley »

I would caution against overusing [Variables] when you don't really need them. You can make things more complicated than they really have to be.

Code: Select all

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

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

[ShowClicks]
Meter=String
MeasureName=ClickCounter
X=0
Y=0
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=17
StringEffect=Shadow
FontEffectColor=0,0,0,255
SolidColor=0,0,0,1
AntiAlias=1
Text=Counter is: %1
LeftMouseUpAction=[!EnableMeasure ClickCounter][!UpdateMeasure ClickCounter][!UpdateMeter ShowClicks][!Redraw]
So we start with ClickCounter disabled. It will be "0". Then when we click, we enable the measure and update it one time so it changes to "1". Since we have UpdateDivider=-1 on the measure, it won't keep counting, but will update only once and stop at "1". Then when you click again, the !EnableMeasure will be ignored as it is already enabled, and it will be updated once again to "2" and stop.

We then just bind the meter to the [ClickCounter] measure, and use that value in the Text option. There is really just no need for the extra step of passing the value through as a [Variable].
test.gif
P.S. In 99.9% of cases you are going to really want LeftMouseUpAction instead of LeftMouseDownAction. Reacting to the "down" press of the mouse button will mean you can no longer drag the skin unless you hold down CTRL while doing it, and unless you want distinct actions on the down and up of the mouse button, for instance to simulate button image changing behavior on "over / down / up", LeftMouseUpAction is going to be a better choice.
You do not have the required permissions to view the files attached to this post.
User avatar
Krainz
Posts: 186
Joined: May 27th, 2012, 5:16 am

Re: Is it possible to make a "Click Counter"?

Post by Krainz »

Thanks!

Now here's the problem: I want to make left clicks add to the square's X and right clicks subtract.

Like, x is 0, then you left click and x becomes 1. x is 1, you right click and it becomes 0

The counter should keep showing the total of both clicks (right and left)

But its not working for some reason

Code: Select all

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

[Variables]
Test=[Calc]
Test2=[Calc2]

[Calc]
Measure=Calc
Formula=([Clickcounter]-[Clickcounter2])

[Calc2]
Measure=Calc
Formula=([Clickcounter]+[Clickcounter2])

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

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

[Meter]
Meter=Image
X=#Test#
Y=1
H=50
W=50
Solidcolor=0,0,255,255
DynamicVariables=1

[ShowClicks]
Meter=String
X=0
Y=0
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=17
StringEffect=Shadow
FontEffectColor=0,0,0,255
AntiAlias=1
Text=[Calc2]
DynamicVariables=1
LeftMouseDownAction=[!EnableMeasure Clickcounter][!UpdateMeasure Clickcounter][!UpdateMeter ShowClicks][!Redraw]
RightMouseDownAction=[!EnableMeasure Clickcounter2][!UpdateMeasure Clickcounter2][!UpdateMeter ShowClicks][!Redraw]
I also have tried with this code, to no success:

Code: Select all

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

[Variables]
Total=[ClickCounter]

[ClickCounter]
Measure=Calc
Formula= Start = 1 ? ClickCounter + 1 : 0
UpdateDivider=-1

[ClickCounter2]
Measure=Calc
Formula= Start = 1 ? ClickCounter2 + 1 : 0
UpdateDivider=-1


[Start]
Measure=Calc
Formula=1
UpdateDivider=-1
[Quadrado]
Meter=Image
Solidcolor=255,255,0,255
H=200
W=200
x=1
y=1
DynamicVariables=1
UpdateDivider=-1
LeftMouseDownAction=[!UpdateMeasure ClickCounter][!UpdateMeter #CURRENTSECTION#][!Redraw]
RightMouseDownAction=[!UpdateMeasure ClickCounter2][!UpdateMeter #CURRENTSECTION#][!Redraw]
[Clicks]
Meter=String
MeasureName=ClickCounter2
;Text=#Total#
x=#Total#
LeftMouseDownAction=[!UpdateMeasure ClickCounter][!UpdateMeter #CURRENTSECTION#][!Redraw]
RightMouseDownAction=[!UpdateMeasure ClickCounter2][!UpdateMeter #CURRENTSECTION#][!Redraw]
[Reset]
Meter=String
Text=x
X=5R
LeftMouseDownAction=[!SetOption ClickCounter Formula 0][!UpdateMeasure ClickCounter][!SetOption ClickCounter Formula "ClickCounter+1][!UpdateMeter Clicks][!Redraw]
RightMouseDownAction=[!SetOption ClickCounter2 Formula 0][!UpdateMeasure ClickCounter2][!SetOption ClickCounter2 Formula "ClickCounter2+1][!UpdateMeter Clicks][!Redraw]
User avatar
jsmorley
Developer
Posts: 21466
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Is it possible to make a "Click Counter"?

Post by jsmorley »

Something like this I guess:

Code: Select all

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

[ClickLeftCounter]
Measure=Calc
Formula=ClickLeftCounter + 1
Disabled=1
UpdateDivider=-1
OnUpdateAction=[!SetOption CurrentX Formula "([CurrentX] + 1)"][!UpdateMeasure CurrentX][!UpdateMeter *][!Redraw]

[ClickRightCounter]
Measure=Calc
Formula=ClickRightCounter + 1
Disabled=1
UpdateDivider=-1
OnUpdateAction=[!SetOption CurrentX Formula "([CurrentX] - 1)"][!UpdateMeasure CurrentX][!UpdateMeter *][!Redraw]

[CurrentX]
Measure=Calc
Formula=0
UpdateDivider=-1
IfCondition=CurrentX < 0
IfTrueAction=[!SetOption CurrentX Formula "0"][!UpdateMeasure CurrentX][!UpdateMeter *][!Redraw]

[MeterImage]
Meter=Image
W=50
H=50
X=[CurrentX]
Y=0
SolidColor=152,235,131,255
DynamicVariables=1

[ShowClicks]
Meter=String
X=0r
Y=0R
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=17
StringEffect=Shadow
FontEffectColor=0,0,0,255
SolidColor=0,0,0,1
AntiAlias=1
Text=Left: [ClickLeftCounter] Right: [ClickRightCounter] CurrentX: [CurrentX]
DynamicVariables=1
LeftMouseUpAction=[!EnableMeasure ClickLeftCounter][!UpdateMeasure ClickLeftCounter]
RightMouseUpAction=[!EnableMeasure ClickRightCounter][!UpdateMeasure ClickRightCounter]
Click to see animation:
test.gif
The trick is going to be when you right click to the point where the value of CurrentX falls below zero. You are going to want to deal with that, which is why I did this:

Code: Select all

[CurrentX]
Measure=Calc
Formula=0
UpdateDivider=-1
IfCondition=CurrentX < 0
IfTrueAction=[!SetOption CurrentX Formula "0"][!UpdateMeasure CurrentX][!UpdateMeter *][!Redraw]
You might also want to limit how far to the right things can go with the same method, using IfCondition2 / IfTrueAction2. Up to you.
You do not have the required permissions to view the files attached to this post.
User avatar
Krainz
Posts: 186
Joined: May 27th, 2012, 5:16 am

Re: Is it possible to make a "Click Counter"?

Post by Krainz »

This is really it, thank you!
User avatar
jsmorley
Developer
Posts: 21466
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Is it possible to make a "Click Counter"?

Post by jsmorley »

Glad to help.
User avatar
Krainz
Posts: 186
Joined: May 27th, 2012, 5:16 am

Re: [Solved] Is it possible to make a "Click Counter"?

Post by Krainz »

Hey, I tried to put a limit of -200 for right clicks on [CurrentX] and it didn't work

Code: Select all

[CurrentX]
Measure=Calc
Formula=0
UpdateDivider=-1
IfCondition=CurrentX <= -200
IfTrueAction=[!SetOption CurrentX Formula "-200"][!UpdateMeasure CurrentX][!UpdateMeter *][!Redraw]
CurrentX keeps going under -200 no matter what.

Also, how do I make [CurrentX] only go to negative values, with a limit of 0? Meaning left cilcks would still count, but they would only move the square if [CurrentX] is lower than 0
User avatar
jsmorley
Developer
Posts: 21466
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Solved] Is it possible to make a "Click Counter"?

Post by jsmorley »

Krainz wrote:Hey, I tried to put a limit of -200 for right clicks on [CurrentX] and it didn't work

Code: Select all

[CurrentX]
Measure=Calc
Formula=0
UpdateDivider=-1
IfCondition=CurrentX <= -200
IfTrueAction=[!SetOption CurrentX Formula "-200"][!UpdateMeasure CurrentX][!UpdateMeter *][!Redraw]
CurrentX keeps going under -200 no matter what.

Also, how do I make [CurrentX] only go to negative values, with a limit of 0? Meaning left cilcks would still count, but they would only move the square if [CurrentX] is lower than 0
Does it really make a lot of sense to have an X option that goes below zero? Any meter with an X less than zero will start "off the skin" and any part of the meter at a skin position less than zero will not display. I don't know, you have sorta lost me. Is someone really going to right click the skin over 200 times to move a meter? I feel like I have lost touch with what the goal is here.
User avatar
Krainz
Posts: 186
Joined: May 27th, 2012, 5:16 am

Re: [Solved] Is it possible to make a "Click Counter"?

Post by Krainz »

I'm using it to make a sidescroll meter, to use the variable as a reference in a skin with various image meters, so the scroll would move them all at the same time without having to move the skin (which has a header, background, etc)

I start with prototypes to test the scrolling through clicks, and when it's ready to go I change it to mousescrollupaction and mousescrolldownaction

And thanks to you I also can use the string meter as a scroll/click counter, which helps making formulas for maximum and minimum values, as well as serving as a click counter for future reference.

The way the project is right now, it has around 10 image meters, which can add up to 30. However, due to the amount of images, the group gets out of the screen, so I need them to scroll left, and thus the negative CurrentX. If I scroll them to the right at their starting position it just feels odd and nothing like a normal scroll would work.

Which is why I need CurrentX to only increase when it's below 0
User avatar
Krainz
Posts: 186
Joined: May 27th, 2012, 5:16 am

Re: [Solved] Is it possible to make a "Click Counter"?

Post by Krainz »

Any ideas on how to make this limit work? For me not even the one that stops it from going negative is working, which should be this one, posted above:
jsmorley wrote:

Code: Select all

[CurrentX]
Measure=Calc
Formula=0
UpdateDivider=-1
IfCondition=CurrentX < 0
IfTrueAction=[!SetOption CurrentX Formula "0"][!UpdateMeasure CurrentX][!UpdateMeter *][!Redraw]

It feels like I'm forgetting something. Maybe DynamicVariables?