It is currently April 27th, 2024, 8:10 am

I need to pass a time to a skin from windows system timer

General topics related to Rainmeter.
User avatar
bobgrosh
Posts: 134
Joined: May 1st, 2011, 10:33 pm

I need to pass a time to a skin from windows system timer

Post by bobgrosh »

I need to pass an event time to a rainmeter skin from windows system timer event.

BACKGROUND:
I use the windows system timer to start and stop my live video camera encoders.
I also use the windows timer to send bangs that hide and show the manual Rainmeter buttons that start and stop cameras. That is so I can prevent operators from messing up scheduled shows.

Now I want to make a countdown meter that displays the remaining time until the end of the show or next scheduled commercial break.

I might be asking the wrong question here, so see the alternate question below.

The skin has a variable like EventTime=0
I already know how to have system scheduler execute the bang to change the EventTime variable to whatever I need.

The question is, how is the internal value for time stored or expressed?
How would I make EventTime equal to 17 seconds past 10:30 am

For example.

Code: Select all

[MeasureHour]
Measure=Time
Format="%H"

[MeasureMinute]
Measure=Time
Format="%M"

[MeasureSecond]
Measure=Time
Format="%S"
Those all let me display the hours, minutes and seconds for the current time.

But, I can not display the actual value of "Time"

Nor is there any obvious way to find the difference in the Time and SetTime

In other systems I would for example use something like this:
RemainingTime=(EventTime - Time)
.
.
.
Format=%H:%M:%S

I suspect I could make measures with calcs to return the hour, min and second based on EventTime instead of Time. Then do the calculation on the hr, min second variables to display te remaining time. I found examples of such methods on DeviantArt, but the code was huge and uggly.

Let's' say a Show starts at 9:05pm and there is a 5 minute commercial break at 9:30pm
At 9:05 the systems timer would start the broadcast and send a bang to set EventTime to 9:30
The countdown meter would then display the results of a calc as the remaining hours, minutes and seconds until the break. It will also have a countdown till the end of the break, a countdown till the end of the show and a countdown till the start of the next show, which could be several days away.

ALTERNATE QUESTION
I realize that I may need to send the event time as several variables, IE: EventY ,EventM, EvenD, EventHr, EventMin, EventSec. In that case, How would I avoid sending 6 bangs? Can I send the event time info in one bang as a comma separated list and then have have code parse it into six different variables. I'm not sure how I'd code that.

Any general suggestions would be appreciated. I know I'll probably get six different answers, all of them good, and all of them educational.
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: I need to pass a time to a skin from windows system time

Post by Chewtoy »

Well, for countdown I would really recommend using Lua to do it. Way easier than doing it natively in rainmeter.
The only bothersome thing about it is that it has some problems with seconds in the countdown, as far as I have been able to tell.

Not sure how you would get the time from system timer though, might be some way to access it. I have never used it though, so not sure.
I don't think, therefore I'm not.
User avatar
bobgrosh
Posts: 134
Joined: May 1st, 2011, 10:33 pm

Re: I need to pass a time to a skin from windows system time

Post by bobgrosh »

Chewtoy wrote:...
Not sure how you would get the time from system timer though, might be some way to access it. I have never used it though, so not sure.
That part is easy, Set up an event time and run Rainmeter.exe !Execute [bang][bang][bang]
The bangs just set a key value like EventHR to 9, EventMin to 60 and Refresh the skin.

My only problem with that is it makes for a long and bothersome command line to set the day, hour, min and sec. I was wondering if I could do it with one bang.

I have no idea why I would use lau, especially if it has problems with the seconds.

Seems like all I have to do in RM is set up calcs for each unit of time and subtract the event time from the actual time and then make a meter for each time unit to display the difference.
Besides, I have no idea where to find a lau interpreter, or where to install it, or where to put the lau code.) So far, I managed to keep my ini's simple with no add in Auto-it or lau codes. Like to keep it that way.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: I need to pass a time to a skin from windows system time

Post by jsmorley »

bobgrosh wrote: That part is easy, Set up an event time and run Rainmeter.exe !Execute [bang][bang][bang]
The bangs just set a key value like EventHR to 9, EventMin to 60 and Refresh the skin.

My only problem with that is it makes for a long and bothersome command line to set the day, hour, min and sec. I was wondering if I could do it with one bang.

I have no idea why I would use lau, especially if it has problems with the seconds.

Seems like all I have to do in RM is set up calcs for each unit of time and subtract the event time from the actual time and then make a meter for each time unit to display the difference.
Besides, I have no idea where to find a lau interpreter, or where to install it, or where to put the lau code.) So far, I managed to keep my ini's simple with no add in Auto-it or lau codes. Like to keep it that way.
You will probably need to do some fair-to-middling complicated calc(s) to convert hours and minutes to seconds, add them to the actual seconds and end up with a big number you can do your subtraction math on, then some more calcs to convert the result back into hours/minutes/seconds for display. I'm not sure treating each time component separately is going to give you the results you want. In any case, there is no generic "timestamp math" functionality in Rainmeter, so it's going to take a bit of doing.

I would certainly do this in Lua and not native Rainmeter myself, but to each his own. By the way, you don't need to install anything to use Lua, it's built into Rainmeter now. You just write a .lua script file with your code, drop it in the same folder with your skin, and call it from Rainmeter with a Measure=Script.

Up to you of course. Even if you would rather not use Lua, and that is fine, you might find the calculations done in the .lua script file in this skin instructive: http://jsmorley.deviantart.com/gallery/#/d37xqbd

Basically

TotalSeconds = (StartingHours * 3600) + (StartingMinutes * 60) + StartingSeconds

Which gives you a big number of seconds you can subtract to find a difference, then something like:

NowHours = floor(TotalSeconds / 3600)
HoursRemainder = floor(TotalSeconds % 3600)
NowMinutes = floor(HoursRemainder / 60)
NowSeconds = floor(TotalSeconds % 60)

To convert the result back into hours/minutes/seconds.

I'm certain this can all be done in native Rainmeter, but it will indeed take a bit of code.
User avatar
bobgrosh
Posts: 134
Joined: May 1st, 2011, 10:33 pm

Re: I need to pass a time to a skin from windows system time

Post by bobgrosh »

jsmorley wrote:...
...
I would certainly do this in Lua and not native Rainmeter myself, but to each his own. By the way, you don't need to install anything to use Lua, it's built into Rainmeter now. You just write a .lua script file with your code, drop it in the same folder with your skin, and call it from Rainmeter with a Measure=Script.

Up to you of course. Even if you would rather not use Lua, and that is fine, you might find the calculations done in the .lua script file in this skin instructive: http://jsmorley.deviantart.com/gallery/#/d37xqbd
...
...
First, Thanks for the code to extract the time. I had it working but my code was much messier. I didn't think to use "FLOOR" which really simplified the code.

Second. It is not that I don't WANT to use lau, it is just a little beyound me.

The link you provided might be a good example, but I must be missing something.

It is a RMSKIN file so installing it was simple.
It is in my skins directory and I can activate it by right clicking the RM icon in the tray, then pick configs - Lautimer - LauTimer.ini

I can tell it is running because if I go back and do it again the checkbox is checked.
I can also tell it is running because I can right click the RM icon and select "About" then in the left panel click on LauTimer. That displays :
MeasureHoursInput 0.0 - 1.0
MeasureMinutesIn... 0.0 - 1.0
MeasureSecondsI... 0.0 - 1.0
MeasureLua 0.0 - 1.0 H:nil M: nil S: nil

This is pretty much the same as all my attempts to run any Lau powered RM skins
Not ever getting any of them to run, I assume the "nil" means it is not working.

Note: I can edit the ini file and remove the lau measure and get the skin to display on the desktop, of course it doesn't work when the measure is commented out, but that is the only way I can even get the skin to display anything. I never found anything on the lau site that told me how to edit the other file in the LauTimer skin directory and it's file type is not recognized by windows. I tried it on three machines, Vista 32 bit. Seven 32 bit and Seven 64 bit.

Oh! I am running 2.1.0 beta
Several weeks ago I tried figuring out Lau, I spent hours and hours with the on-line manual at Rm and the Lau web site but never really got anything to work.

OK, I must be stupid and am missing something. So do your magic and say that short little sentence that will make me slap my head and say. Duh!

Thanks

Oh, I am running RM version 2.1.0 beta
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: I need to pass a time to a skin from windows system time

Post by jsmorley »

MeasureHoursInput 0.0 - 1.0
MeasureMinutesIn... 0.0 - 1.0
MeasureSecondsI... 0.0 - 1.0
MeasureLua 0.0 - 1.0 H:nil M: nil S: nil

Is exactly what you should see when you first load the skin and it is not actively counting down. Once you set one or more of the timer amounts (just click the numbers, put in what you want and hit enter) then click the check mark / go icon, it will start counting down in the "About" output for MeasureLua, and of course in the skin itself. When your timer reaches zero in hours/mins/secs it will play the alarm.

The other measures (like MeasureHoursInput for instance) are InputText plugin measures, and are used to capture input from you, not to gather information to be used in a meter like most other measures, and will never display any value in "About". They are used to gather user input, then write those values as permanent [Variables] in the skin, which the Lua uses. The InputText plugin stuff is sorta irrelevant to what you are doing, and I wouldn't worry too much about those measures right now. I mostly just wanted to show that you can do a lot of math in Lua with a handful of lines, instead of tons of Measure=Calc statements in native Rainmeter.

P.S. "nil" does not mean "error" in Lua, but only means "no value". About will always show that when the timer is not actively running.
User avatar
bobgrosh
Posts: 134
Joined: May 1st, 2011, 10:33 pm

Re: I need to pass a time to a skin from windows system time

Post by bobgrosh »

jsmorley wrote:MeasureHoursInput 0.0 - 1.0
...
...Once you set one or more of the timer amounts (just click the numbers, put in what you want and hit enter) then click the check mark / go icon, it will start counting down
...
I still don't understand....
How am I supposed to click the numbers when it is not running....

The skin does not display anything . There is nothing to click, no boxes to put data into.


I see a rectangle with three numbers on the preview picture at the link where I downloaded LauTimer, but I don't get ANYTHING DISPLAYED on my DESKTOP when I run LauTimer, or for that matter, any skin with lau in it.

The ONLY indication I get that the skin is running is from the checkbox at RM-Config-LauTimer-Lautimer.ini and in the display of RM-About
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: I need to pass a time to a skin from windows system time

Post by jsmorley »

Sure it's not hidden behind something or otherwise off the screen? Try going into RainBrowser while that skin is loaded, and under the "Active" tab find the skin then click "Skin Settings". Set the WindowX and WindowY both to zero (top left corner of your monitor) and click "Apply" then "Return".

It should be there in the upper left of your monitor.
User avatar
bobgrosh
Posts: 134
Joined: May 1st, 2011, 10:33 pm

Re: I need to pass a time to a skin from windows system time

Post by bobgrosh »

jsmorley wrote:Sure it's not hidden behind something or otherwise off the screen?
Nope.
But, I found the problem.

When I downloaded the latest beta, I put it in dropbox and installed it on 4 computers from dropbox

I just put the same download in dropbox again and reinstalled it a second time on three of the four computers and now it works on those three.

Now skins with lau show up on the desktop.

Now that I can see the skins I am less confused about lau, it dawned on me to look at the lau file with gander and realized it is not a compiled file so I associated it with notepad and can now read the lau scripts.

Duh!

Thanks you guys are the best.