Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1082

Community Plugins & Addons • Timer

$
0
0
I'm pretty excited for the release of my first (released) plugin (that I made from the ground up) :D.

This plugin came from the idea to make an "intervalometer" to use nstechbytes' Finalshot plugin to create gifs. However I saw its potential as a timer plugin so I added many more things to it, I hope you find it useful. Let's get into it.

Timer Plugin provides timing functionality (typically accurate to within a few milliseconds, subject to the limits of the underlying OS timer and task scheduler) and supports both count‑up and countdown modes. Total duration and interval can each be specified in any time unit (from milliseconds to days), with support for exact time and date. Can execute bangs on start, tick, pause, resume, stop, dismiss, and reset events. It offers automatic measure updates, time formatting codes (including total seconds, total milliseconds and tick counts). It's sole purpose is to offer an easy way to create timer skins.

A.gif
This gif was made entirely in Rainmeter using Finalshot + Timer plugins (and gifski).

✨ Features
  • Multiple Output Units: Output elapsed/remainig milliseconds, seconds, minutes, hours, days and tick count.
  • Custom Formatting: Supports Time Measure-like TimeStamp Code formatting.
  • Control: Start it, Stop it, Pause it, Resume it, Reset it, Dismiss it, Toggle it.
  • Set the time: Specify the time for the timer to stop at.
  • A banger: Execute bangs on any event.
  • Intervals: Execute bangs at intervals (ticks).
📥 Download & Installation

The package includes the plugin plus 5 simple timer example skins.

TimerPlugin_1.0.rmskin

👏 Huge Thanks
  • To Yincognito who helped me testing.
  • To anyone who dares testing it and then share their experience :)
📝 Changelog

v1.0.0
  • Initial release!

Documentation


📌 How to Use




For simple and basic timer, create your timer measure like this:

Code:

[Timer]Measure=PluginPlugin=TimerDurationUnits=SecondsDuration=35Update=1000OnStopAction=[!Log "Time's up!"]
The measure will update every second, and will return a string like this: 00:00:00 which is: hh:mm:ss, finally it will stop automatically after 35 seconds have past and will log "Time's Up!". If DurationUnits is not set, the Duration will have to be entered in milliseconds.

When Duration=-1, the timer will run until manually stopped.

Start it using LeftMouseUpAction=[!CommandMeasure Timer "Start"] and manually Stop it using LeftMouseUpAction=[!CommandMeasure Timer "Stop"].

You can also toggle it like: LeftMouseUpAction=[!CommandMeasure Timer "Toggle"]

Please read the next sections to see all available options and commands.

The measure will only update while the timer is running.

The plugin is not affected by the [Rainmeter] Update, so there’s no need to set UpdateDivider=-1. This is to avoid sync problems between RM updates and the actual elapsed time.
If no time display is needed, you can set Update=-1. The measure won't update but the timer will continue to work normally.


🏷️ Measure Values



  • Number Value
    Returns the state of the timer
    • 0 Stopped.
    • 1 Running.
    • 2 Paused.


  • String Value
    By default it returns the elapsed time in hh:mm:ss format. The string can be changed to different formats using Format Codes in the measure's Format option, it works similar to the Format option of the Time measures.
    Examples:
    • Format= Total Elapsed Seconds: %ts will return: Total Elapsed Seconds: 2675.
    • Format= Hour: %H Minute: %M Second: %S will return: Hour: 01 Minute: 25 Second: 08.
    • Format= %k will return the total ticks count: 125.
    Please check the Format Codes section to see all available codes.

    When Countdown=1 it will return the remaining time instead.



✒️ Format Codes


The following format codes can be used on the measure's Format option, Action options, and Section Variables.
  • %D: Whole days, padded with leading zeros.
  • %H: Whole hours that aren't counted as part of days. Single-digit hours have a leading zero.
  • %M: Whole minutes that aren't included as part of hours or days. Single-digit minutes have a leading zero.
  • %S: Whole seconds that aren't included as part of hours, days, or minutes. Single-digit seconds have a leading zero.
  • %F: Tenths of a second. Nothing is displayed if the digit is zero.
  • %FF: Hundredths of a second. Any fractional trailing zeros or two zero digits aren't included.
    Note: these can be up to 7 units: %FFFFFFF (Ten-millions of a second. Any fractional trailing zeros or seven zeros aren't displayed.)
  • %d: Whole days.
  • %h: Whole hours that aren't counted as part of days. Single-digit hours don't have a leading zero.
  • %m: Whole minutes that aren't included as part of hours or days. Single-digit minutes don't have a leading zero.
  • %s: Whole seconds that aren't included as part of hours, days, or minutes. Single-digit seconds don't have a leading zero.
  • %f: Tenths of a second.
  • %ff: Hundredths of a second.
    Note: these can be up to 7 units: %fffffff (Ten-millions of a second.)
  • %T: Short for hh:mm:ss.ff
  • %t: Short for hh:mm:ss
  • %td: Total elapsed whole days.
  • %th: Total elapsed whole hours.
  • %tm: Total elapsed whole minutes.
  • %ts: Total elapsed whole seconds.
  • %tms: Total elapsed whole milliseconds.
  • %tfd: Total elapsed fractional days.
  • %tfh: Total elapsed fractional hours.
  • %tfm: Total elapsed fractional minutes.
  • %tfs: Total elapsed fractional seconds.
  • %k: Total ticks.


⚙️ Options


  • Update
    Default: 1000

    Defines the update interval of the measure in milliseconds.

    Values:
    • <= 0 Disabled
    • > 0 Enabled
The plugin measure will not update until started, once started it will update once every 1000ms (1 second) by default.

When Update=-1, the measure will not update but the timer will run and work normally. The only difference is that the measure will not display the elapsed/remaining time.

The lowest possible value for Update is 1, however, setting the Update this low doesn't offer better precision, for most tasks leaving it at 1000 is just fine. If a low update is required, setting it at 16 is the lowest recommended.

The timer itself runs on a different thread, this means that it doesn't depend on Rainmeter's Update to work, this Update value is only the rate at which the plugin's measure is updated to report the timer's elapsed/remaining time to Rainmeter by updating its Number and String values.

The measure will also update automatically when executing any command that changes its state (Start, Stop, Pause, Resume, Reset, Dismiss) even if Update=-1 is set, the update will occur before executing the actions. For example, if [!CommandMeasure Timer Stop], the timer will first stop, then it will update the measure and finally will execute the OnStopAction. The same order applies to all other commands.

In short, if you don't need to display the elapsed\remaining time, then simply leave Update=-1, the timer will still run normally.
if you need to display the time, or use the string value for anything else, set Update=1000 (or lower if needed).
If you only need to display the time on each tick, set Update and Interval to the same value.

However, if your skin will only display the time given by the timer and nothing else that needs regular updating, is recommended to set Update=-1 on [Rainmeter] to avoid the regular skin updates from interfering with the plugin’s measure update. This can be noticed on the Alarm example skin, where sometimes it will jump from e.g 48 to 46 (missing 47). However this won’t stop the plugin from ticking at the right time because again, the timer is in a separate thread and it will continue regardless of the Rainmeter’s update cycle. The OnTickAction is still executed at the right moment. To “fix” it, simply set Update=-1 on [Rainmeter] section.



  • Format
    Default: %t

    Defines the format string returned by the measure. It works pretty much like the Format option of the Time measure.

    Values:
    • "Any string with or without %Codes"
It can use any Format Code from the Format Codes list to return the formatted elapsed time on every measure update.

Example: Format= %H-%M-%S will return the elapsed/remaining time as 07-25-32

Check Format Codes section to see all available format codes.



  • DurationUnits
    Default: Milliseconds

    Defines the units the Duration option will take.

    Values:
    • 1 or ms or mil or millisecond or milliseconds
    • 2 or s or sec or second or seconds
    • 3 or m or min or minute or minutes
    • 4 or h or hour or hours
    • 5 or d or day or days
Although you can set e.g. DurationUnits=2, the option itself can't take math directly, as it is in reality a string option, not a number option.


  • Duration
    Default: -1

    Defines the duration of the timer in the units set by the DurationUnits option.

    Values:
    • <= 0: Disabled
    • > 0: Timer duration
Once the timer reaches the set duration it will stop automatically and will execute the OnStopAction.

When Duration=-1 (or any value <= 0) the timer will run until manually stopped.

if ResetOnStop is enabled, the timer will return to 00:00:00 when it stops.

All units take fractional numbers except milliseconds, any fraction in ms will be floored to the nearest integer.



  • TargetTime
    Default: ""

    Defines the duration of the timer with a formatted time string.

    Values:
    • 2025/04/26 06:48:17: The timer will stop on April 26, 2025 at 06:48:17 AM.
When a TargetTime string is given, the Duration value is ignored.

Some valid time string formats include:

Full date and time:
  • 2025-04-19 16:30
  • April 19, 2025 4:30 PM
  • 4/19/2025 16:30
  • 19/04/2025 16:30
Date only:
  • 2025-04-19
  • April 19, 2025
  • 4/19/2025 or 19/04/2025 or 04/19/2025
Time only:
  • 4:30 PM
  • 4:30 AM
  • 16:30
  • 04:30 (24-hour)
When a time-only value is given, it will assume today's date. If the time has already passed, is then assumed to be tomorrow.
If a date in the past that is greater than one day is given, it will fail and start with duration=-1. An error will be logged.

If an invalid format is given, then it will start with duration=-1. An error will be logged.

To use a specific date format, use the FormatLocale option.



  • FormatLocale
    Default: ""

    An optional value that defines the "language - locale" that the formatted date / time string defined in TargetTime is in.

    Example:
    • es-MX
For a list of all valid locales visit: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c

If this option is not defined, the plugin will compare the given TargetTime string to a set list of common locales.

Examples:

FormatLocale=lo-LA
TargetTime=25 ເມສາ 2025

FormatLocale=cy-GB
TargetTime=25 Ebrill 2025



  • IntervalUnits
    Default: Milliseconds

    Defines the units the Interval option will take.

    Values:
    • 1 or ms or mil or millisecond or milliseconds
    • 2 or s or sec or second or seconds
    • 3 or m or min or minute or minutes
    • 4 or h or hour or hours
    • 5 or d or day or days
Although you can set e.g. IntervalUnits=3, the option itself can't take math directly, as it is in reality a string option, not a number option.



  • Interval
    Default: -1

    Defines the interval in the units set by the IntervalUnits option at which the timer will execute the OnTickAction.

    Values:
    • <= 0: Disabled
    • > 0: Tick interval
For example, if IntervalUnits=Hours and Interval=1, the timer will execute the OnTickAction once an hour.

When Interval<=0, the OnTickAction will never be executed.

Every time the timer reaches the interval, it counts a "tick" up. The total ticks count can be returned by using the Format Code %k on the Format option, the OnTickAction or on any other action.

All units take fractional numbers except milliseconds, any fraction in ms will be floored to the nearest integer.

Note: It is important to understand that the timer has a delay of around +-16ms, this means that if you set an interval every 1000ms, those intervals won't tick at exactly 1000ms. More like 1003ms, 1018ms, 998ms, etc.



  • Countdown

    Sets the timer to return the remaining time instead of the elapsed time.

    Default: -1
    Values:
    • -1: Disabled
    • 1: Enabled
If enabled, and Duration or TargetTime are set, the strings returned by the Format Codes will start from the Duration and will Stop at zero.

In other words, when Countdown=1, the timer will return the remaining time instead of the elapsed time.



  • ResetOnStop
    Default: 1

    If disabled, the string value of the measure won't be reset to zero when the timer stops.

    Values:
    • -1: Disabled
    • 1: Enabled


Actions
The following actions can use the Format Codes to export the timer's elapsed time.



  • OnStartAction
Executes given bangs when the timer Starts.

Example: OnStartAction= [!Log "The timer has started at %t."]

Logs: The timer has started at 00:25:00. (when countdown=1)



  • OnStopAction
Executes given bangs when the timer Stops.

Example: OnStopAction= [!Log "The timer has stopped on tick %k."]

Logs: The timer has stopped on tick 325.



  • OnResumeAction
Executes given bangs when the timer Resumes.

Example: OnResumeAction= [!Log "The timer has been resumed at minute %M."]

Logs: The timer has been resumed at minute 35.



  • OnPauseAction
Executes given bangs when the timer Pauses.

Example: OnPauseAction= [!Log "The timer was paused at %T."]

Logs: The timer was paused at 00:25:37.125.



  • OnDismissAction
Executes given bangs when the timer is Dismissed.

Example: OnDismissAction= [!Log "Timer dismissed at %H:%M."]

Logs: The timer was paused at 05:25.



  • OnResetAction
Executes given bangs when the timer is reset.

Example: OnResetAction= [!Log "Reset after %h hours and %m minutes."]

Logs: Reset after 5 hours and 3 minutes.



  • OnTickAction
Executes given bangs when the timer reaches the set interval (ticks).

Example: OnTickAction= [!Log "Tick %k."]

Logs: Tick 27.



🛠️ Commands



The following commands are used with the [!CommandMeasure MeasureName "Command"] bang.



  • Start
    • Starts and executes the OnStartAction.
Example: [!CommandMeasure MeasureName "Start"]



  • Stop
    • Stops and executes the OnStopAction.
Example: [!CommandMeasure MeasureName "Stop"]



  • Toggle
    • Toggles the timer and executes the OnStartAction or OnStopAction.
Example: [!CommandMeasure MeasureName "Toggle"]



  • Resume
    • If not running, first it will Start and then will execute OnStartAction.
    • If paused, it will Resume and execute OnResumeAction.
Example: [!CommandMeasure MeasureName "Resume"]



  • Pause
    • Pauses and executes OnPauseAction.
Example: [!CommandMeasure MeasureName "Pause"]



  • ToggleResume
    • If not running, it will Start and execute OnStartAction.
    • If running, it will Pause and execute OnPauseAction.
    • If paused, it will Resume and execute OnResumeAction.
Example: [!CommandMeasure MeasureName "ToggleResume"]



  • Reset
    • If running, it will restart from 0 and execute OnStartAction.
    • If paused, it will Stop and execute OnResetAction.
    • If not running and not at 0, it will reset to 0 and execute OnResetAction.
    When Countdown=1, it will reset to the Duration.
Example: [!CommandMeasure MeasureName "Reset"]



  • Dismiss
    • Stops the timer and executes OnDismissAction.
Example: [!CommandMeasure MeasureName "Dismiss"]
🪄 Section Variables


  • TimeStamp or TS
    • Argument: "String"
    • Default: %t
Returns the elapsed time formatted using Format Codes.

Examples:
[&Measure:TimeStamp()] or [&Measure:TS()] will return the elapsed time in 00:00:00 format: 12:25:17.
[&Measure:TimeStamp("%ts")] or [&Measure:TS("%ts")] will return the total elapsed time in whole seconds: 2600.
[&Measure:TimeStamp("Hour: %h, Minute: %m")] or [&Measure:TS("Hour: %h, Minute:%m")] will return the string Hour: 5, Minute: 25.

If Countdown=1 is set on the measure, it will return the remaining time.

Note: DynamicVariables=1 is required to be set on the Measure\Meter where the section variable is used on.



Statistics: Posted by RicardoTM — Today, 1:45 am — Replies 3 — Views 153



Viewing all articles
Browse latest Browse all 1082

Trending Articles