It is currently March 29th, 2024, 2:56 pm

How to make a simple hour tracker?

Get help with creating, editing & fixing problems with skins
Evil_Hamster
Posts: 3
Joined: May 13th, 2018, 10:30 pm

How to make a simple hour tracker?

Post by Evil_Hamster »

Hi all.

I want to make a meter that counts the hours from a given time period. (I.e. I set the time and it keeps counting. But it should continue after a restart. So not just like an uptime counter, but one that continues from a certain timeperiod).

Anyone know of a meter, or how to make one?

Cheers.
Evil_Hamster
Posts: 3
Joined: May 13th, 2018, 10:30 pm

Re: How to make a simple hour tracker?

Post by Evil_Hamster »

Any suggestions?
Cheers
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: How to make a simple hour tracker?

Post by eclectic-tech »

Evil_Hamster wrote:Hi all.

I want to make a meter that counts the hours from a given time period. (I.e. I set the time and it keeps counting. But it should continue after a restart. So not just like an uptime counter, but one that continues from a certain timeperiod).

Anyone know of a meter, or how to make one?

Cheers.
The "gotcha" is keeping time even when the skin is unloaded or the computer is turned off...
killall-q created a timer that uses a script to achieve this behavior. It may give you an idea on how to go about starting your project: T-Minus Skin

Perhaps one of the lua programmers can supply you with a simpler script that tracks os.time(); not something I want to tackle. :17denial
Evil_Hamster
Posts: 3
Joined: May 13th, 2018, 10:30 pm

Re: How to make a simple hour tracker?

Post by Evil_Hamster »

Thank you for your help. It is much appreciated.

I will have a look at the "T-Minus".

If anyone per chance has a finished script, I would appreciate it:)
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: How to make a simple hour tracker?

Post by kyriakos876 »

Evil_Hamster wrote:Thank you for your help. It is much appreciated.

I will have a look at the "T-Minus".

If anyone per chance has a finished script, I would appreciate it:)
If I understood correctly, this might help:

Code: Select all

[Rainmeter]
Update=1000
OnUpdateAction=[!SetVariable Time [MeasurePace]][!UpdateMeter Meter][!Redraw][!WriteKeyValue Variables StoppedAt [MeasurePace]]
OnRefreshAction=[!SetVariable Time #StoppedAt#][!Update]
MouseScrollDownAction=[!Refresh]

[Variables]
Time=0
StoppedAt=0

[MeasurePace]
Measure=Calc
Formula=(#Time#+1)
DynamicVariables=1

[Meter]
Meter=String
Text=#Time#
FontSize=30
FontColor=255,255,255
DynamicVariables=1
This is a counter for 1 second, if you want to display hours, you can simply add another meter and one more measure for the hours or whatever you want. I would write the code but I think it's obvious how to do it from here.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: How to make a simple hour tracker?

Post by eclectic-tech »

kyriakos876 wrote:If I understood correctly, this might help:

Code: Select all

[Rainmeter]
Update=1000
OnUpdateAction=[!SetVariable Time [MeasurePace]][!UpdateMeter Meter][!Redraw][!WriteKeyValue Variables StoppedAt [MeasurePace]]
OnRefreshAction=[!SetVariable Time #StoppedAt#][!Update]
MouseScrollDownAction=[!Refresh]

[Variables]
Time=0
StoppedAt=0

[MeasurePace]
Measure=Calc
Formula=(#Time#+1)
DynamicVariables=1

[Meter]
Meter=String
Text=#Time#
FontSize=30
FontColor=255,255,255
DynamicVariables=1
This is a counter for 1 second, if you want to display hours, you can simply add another meter and one more measure for the hours or whatever you want. I would write the code but I think it's obvious how to do it from here.
Using the UPDATE rate of the skin to track time is going to be very inaccurate! If any skin causes a delay, the actual "time" between updates is NOT 1 SECOND; over time, this is going to give erroneous results.

It would be much better to use a Time Measure that will give you the actual number of seconds, no matter what Rainmeter is doing.

However, the OP wanted something that would continue to count even with a restart. The T-Minus skin will start counting (of course in milliseconds) and continue to count time until it is told to stop. It will do this if the skin is refreshed, even if the skin is unloaded, and even if the computer is shut down...

I think using T-Minus code is his best option. He can use that skin to keep count and display the hours any way he wants.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: How to make a simple hour tracker?

Post by kyriakos876 »

eclectic-tech wrote:Using the UPDATE rate of the skin to track time is going to be very inaccurate! If any skin causes a delay, the actual "time" between updates is NOT 1 SECOND; over time, this is going to give erroneous results.

It would be much better to use a Time Measure that will give you the actual number of seconds, no matter what Rainmeter is doing.

However, the OP wanted something that would continue to count even with a restart. The T-Minus skin will start counting (of course in milliseconds) and continue to count time until it is told to stop. It will do this if the skin is refreshed, even if the skin is unloaded, and even if the computer is shut down...

I think using T-Minus code is his best option. He can use that skin to keep count and display the hours any way he wants.
I know this is going to inaccurate. You could make it easily accurate by using the system's time instead of the measure I used but I was lazy enough to share this way. I was going to add that it will only count as long as the skin is loaded and will delay as Rainmeter takes more time to load than windows do. Honestly, I thought this was obvious enough. Also, it always depends on the use OP wants to do. If he wants for example to count how much time is Rainmeter running, this would work.