It is currently May 20th, 2024, 6:30 am

Simple stopwatch [Edit to Simple Elapsed Time]

Get help with creating, editing & fixing problems with skins
User avatar
HLHM
Posts: 7
Joined: August 13th, 2023, 2:07 pm

Simple stopwatch [Edit to Simple Elapsed Time]

Post by HLHM »

Hi.

I want a simple stopwatch.
It does not count seconds, only minutes and hours.
Click on it to reset and restart.

I'm new to this and don't know where to start. Grateful for help.
Last edited by HLHM on August 13th, 2023, 6:57 pm, edited 1 time in total.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5412
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Simple stopwatch

Post by eclectic-tech »

HLHM wrote: August 13th, 2023, 2:10 pm Hi.

I want a simple stopwatch.
It does not count seconds, only minutes and hours.
Click on it to reset and restart.

I'm new to this and don't know where to start. Grateful for help.
Skin requests are not supported in this forum...
However, here is a dynamic stopwatch by raiduard: Stopwatch
or a simple countdown timer by JSMorley to try: TimerNixie

If you need to customize them, simply ask your question here.
User avatar
HLHM
Posts: 7
Joined: August 13th, 2023, 2:07 pm

Re: Simple stopwatch

Post by HLHM »

Hi. I wasn't looking for a finished skin but the code in its simplest form.
Realize that it's not the stopwatch I need, but the time that has passed since the refresh
When I have understood it, I will build further, but right now I have no idea how. Thanks
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5412
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Simple stopwatch

Post by eclectic-tech »

HLHM wrote: August 13th, 2023, 2:49 pm Hi. I wasn't looking for a finished skin but the code in its simplest form.
Realize that it's not the stopwatch I need, but the time that has passed since the refresh
When I have understood it, I will build further, but right now I have no idea how. Thanks
You can start from nothing if you like, but it should be much easier to modify an existing skin that already deals with time; the TimerNixie skin does that and with small changes could result in what you are looking for; it shows remaining time from a set date and time.

If you want to start completely new, here are some helpful links for you to study:
Time Measure
Time & Uptime Measures

Good luck and feel free to ask questions, it's how we all started :welcome:
User avatar
HLHM
Posts: 7
Joined: August 13th, 2023, 2:07 pm

Re: Simple stopwatch

Post by HLHM »

Thanks. Part one is complete. Mixed from what I found here on the forum and managed to get it working. Now for part 2, clicking and restarting the counter. This is fun but now it's time for a coffee :)

Code: Select all


[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=0,0,0,255

[mStartingTime]
Measure=Time
UpdateDivider=-1

[mTimeNow]
Measure=Time

[mTimmar]
Measure=Time
TimeStamp=([mTimeNow:]-[mStartingTime:])
DynamicVariables=1
Format=%#H

[mMinuter]
Measure=Time
TimeStamp=([mTimeNow:]-[mStartingTime:])
DynamicVariables=1
Format=%M

[Meter1]
Meter=String
MeasureName=mTimmar
MeasureName2=mMinuter
FontFace=Trebuchet MS
FontSize=12
FontWeight=400
FontColor=255,255,255,255
Text="Elapsed time since last COFFEE break: %1 hour %2 minutes!"

User avatar
Yincognito
Rainmeter Sage
Posts: 7291
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple stopwatch

Post by Yincognito »

HLHM wrote: August 13th, 2023, 2:49 pm Hi. I wasn't looking for a finished skin but the code in its simplest form.
Realize that it's not the stopwatch I need, but the time that has passed since the refresh
When I have understood it, I will build further, but right now I have no idea how. Thanks
Time that has passed since the refresh of the skin, or time that has passed since you clicked to start the stopwatch?

Both can be solved in a simple way. You need a basic Time measure, and an equally basic Uptime measure having a SecondsValue option. Then, in the meter where you show the text result, add some appropriate LeftMouseUpAction where you set a variable named, say, StartTime, to the timestamp value of the Time measure on left click. As a consequence, the value of the SecondsValue option from the Uptime measure should be set to the timestamp value of the Time measure (i.e. the current time as a number) minus the value of the variable you just created (i.e. the start time as a number). The Uptime measure would format that numerical difference in seconds to days, hours, minutes and so on, depending on what you set as the value of its Format option. As long as the meter references the Uptime measure and displays it, you're good to go. Resetting can be simulated by creating another variable, say, Reset, which you can multiply the above difference with, in the SecondsValue option from the Uptime measure. Obviously, you should set the value of the newly created Reset variable to 0, in a, say, RightMouseUpAction that you add to the meter (to reset) taking care to set it to 1 in the LeftMouseUpAction (to count time).

Check the code at
https://forum.rainmeter.net/viewtopic.php?t=42717#p217029
and adjust it as mentioned, removing the unneeded stuff, and take a look at
https://docs.rainmeter.net/manual/skins/option-types/#Action
to see how to set variables using mouse actions.

Also, you should check
https://docs.rainmeter.net/manual/bangs/#UpdateMeasure
https://docs.rainmeter.net/manual/bangs/#UpdateMeter
https://docs.rainmeter.net/manual/bangs/#Redraw
to see how to update the measures and meters relevant to the changes you make, and redraw the skin afterwards in order to make those changes visible in the skin.

EDIT: Well, looks like you got a nice start already, but the above is still applicable. ;-)

P.S. The Uptime measure and the meter would need to have a DynamicVariables=1 line added to them, so that Rainmeter sees the changes in those variables.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
HLHM
Posts: 7
Joined: August 13th, 2023, 2:07 pm

Re: Simple stopwatch

Post by HLHM »

Thanks for your help.

I put the line

Code: Select all

LeftMouseUpAction=!UpdateMeasure mStartingTime
in the Meter1-section and it did the trick.
User avatar
Yincognito
Rainmeter Sage
Posts: 7291
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple stopwatch

Post by Yincognito »

HLHM wrote: August 13th, 2023, 6:45 pm Thanks for your help.

I put the line

Code: Select all

LeftMouseUpAction=!UpdateMeasure mStartingTime
in the Meter1-section and it did the trick.
Sure thing. Just another way of doing the same - your code does it using a measure, while my approach would have done it using a variable. Both ways are valid, as long as you get the desired outcome.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth