It is currently September 20th, 2019, 8:26 am

Choosing a different Image depending on the time

Help with creating, editing & fixing problems with skins
Saproko17
Posts: 1
Joined: July 25th, 2019, 9:22 pm

Choosing a different Image depending on the time

Saproko17 » July 25th, 2019, 9:47 pm

Hey!
I'm new to Rainmeter and tried to figure most of how it works myself. I got some Code snippets from the internet but I don't manage to get my skin working as it should. The aim is to create a skin that changes the desktop wallpaper at a certain time to a night theme and then change it back to day theme in the morning. Additionaly there is another image layer which is in front of the Equalizer. There is also a night and a day version for that image but i cannot figure out how to change the ImageName so that it automatically picks the right file, depending on the time.

Code: Select all

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

[MeasureTime]
Measure=Time
Format=%H%M

[MeasureEqual]
Measure=Calc
IfCondition=(MeasureTime > 0700) && (MeasureTime < 2100)
IfTrueAction=[!SetWallpaper "nms_day.jpg"]
IfCondition2=(MeasureTime > 2100) || (MeasureTime < 0700)
IfTrueAction2=[!SetWallpaper "nms_night.jpg"]

[Image]
Meter=Image
ImageName=nms_night_cut.png
x=0
y=0
w=1920
h=1080

The part with the wallpaper works but again i don't know how i should do the other layer. I tried out various things but nothing worked for me...

I am looking forward to your answers :)
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3543
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Choosing a different Image depending on the time

eclectic-tech » July 26th, 2019, 1:30 am

When you set the wallpaper, add bangs to set the ImageName option of the Image meter to the corresponding cut image, update that meter, and redraw it. The action would be the same for day or night, only the ImageName value is different.

Code: Select all

[MeasureEqual]
Measure=Calc
IfCondition=(MeasureTime >= 0700) && (MeasureTime < 2100)
IfTrueAction=[!SetWallpaper "nms_day.jpg"][!SetOption Image ImageName "nms_day_cut.png"][!UpdateMeter Image][!Redraw]
IfCondition2=(MeasureTime >= 2100) || (MeasureTime < 0700)
IfTrueAction2=[!SetWallpaper "nms_night.jpg"][!SetOption Image ImageName "nms_night_cut.png"][!UpdateMeter Image][!Redraw]

[Image]
Meter=Image
ImageName=nms_night_cut.png
x=0
y=0
w=1920
h=1080
User avatar
balala
Rainmeter Sage
Posts: 8626
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Choosing a different Image depending on the time

balala » July 26th, 2019, 4:01 pm

A few comments here:
  • I don't see a reason to use the [MeasureEqual] measure. Its only purpose is to run the IfConditions, but these options can be added directly to the [MeasureTime] measure and this way the [MeasureEqual] measure isn't even needed any more. The fewer measure, the betters.
  • There are not needed nor the two IfConditions. One single is completely enough. When the first is not true, the second one is and vice-versa: when the second is not true, the first is, so one IfCondition with one IfTrueAction and one IfFalseAction is enough.
  • If the only reason of this code is to change the wallpaper, there is no need to have any seeable image. So, if there really no need of it, I'd use a simple "dummy" meter (I commented out the not needed options of the [Image] meter). If so, nor the DynamicWindowSize doesn't have to be set into the [Rainmeter] section (also commented out). But if you want to see something on the screen, just ignore this.
  • Dynamic variables can't be set into the [Rainmeter] section, this option isn't supported there. It is supported only on meters and measures, so has to be set onto each of them, one by one (commented out as well).
So, this is how I'd modify the code, to keep it as short as possible:

Code: Select all

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

[MeasureTime]
Measure=Time
Format=%#H%M
IfCondition=((#CURRENTSECTION#>0700) && (#CURRENTSECTION#<2100))
IfTrueAction=[!SetWallpaper "nms_day.jpg"][!SetOption Image ImageName "nms_day_cut.png"][!UpdateMeter "Image"][!Redraw]
IfFalseAction=[!SetWallpaper "nms_night.jpg"][!SetOption Image ImageName "nms_day_cut.png"][!UpdateMeter "Image"][!Redraw]

[Image]
Meter=Image
;ImageName=nms_night_cut.png
X=0
Y=0
W=1920
H=1080
Note that in the above code I also rewrote the IfCondition with the #CURRENTSECTION# variable instead of MeasureTime (when used into the [MeasureTime] measure, #CURRENTSECTION# is equal to MeasureTime) and added a # into the Format option of the [MeasureTime] measure, because it's better to not have the leading zeros on hours in this measure, to not have a number beginning with zero on AM.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3543
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Choosing a different Image depending on the time

eclectic-tech » July 27th, 2019, 2:38 am

The original poster said they needed to change the overlay image; [Image] meter. You eliminated it... :confused:

They had no problem with how they were changing the wallpaper. Yes, the code could be "optimized" but I would first solve their issue as simply as possible, then offer "suggestions" to optimize, if they desired them.

I understand your points, but unless something in the code creates errors, I think we can be too critical at times... O.O

A nudge can be more encouraging than a two-handed push...
User avatar
balala
Rainmeter Sage
Posts: 8626
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Choosing a different Image depending on the time

balala » July 27th, 2019, 6:10 am

eclectic-tech wrote:
July 27th, 2019, 2:38 am
The original poster said they needed to change the overlay image; [Image] meter. You eliminated it... :confused:

They had no problem with how they were changing the wallpaper.
Oups, you're right, it seems.
Ok, I'm editing the code I've posted to add back the commented out meter and add the appropriate !SetOption bangs, as you did.
eclectic-tech wrote:
July 27th, 2019, 2:38 am
I understand your points, but unless something in the code creates errors, I think we can be too critical at times... O.O
Are you talking about my code? Does it gives errors?

Sorry for my mistake. :confused:
User avatar
Vx_Lotus
Posts: 34
Joined: July 30th, 2019, 7:37 am

Re: Choosing a different Image depending on the time

Vx_Lotus » July 30th, 2019, 7:58 am

This is my mess but i'm working with gifs... I tried to use the counter but I cant figure out rainmeters program structure... i'm just not used to it.
***wait 3 seconds then load another gif that plays once. or Load and play once emediately after .wav has ended***

[gif 1 = 36 frames, ;gif 2 = 86 frames.] :jawdrop
[gif 1 stays playing constantly (FUTURE COMPUTER ASSISTANT)] :o
[gif 2 plays once ] :uhuh:
[then when it closes I was going to load in a new cpu core image skin.. ]
[Right now click - 2 skins load, plays gif 1 but doesn't start gif 2 or play gif 2 after 5 seconds.] :confused:
[these 2 loads run off a main] :?

At this point I was thinking of starting over with these 2 and going about it a different way. :thumbdown:
The parent gif loads gif main() then gif Main() controls ----loading \unloading gifs\sounds\skins these below are supposed to be a small part of that sequence. My question is. If that code works for a picture or image, will it work with gifs? or is there a guaranteed way to do this? :???:

Code: Select all

[MeasureOnLoad]
Measure=Calc
Formula=Counter
IfCondition=MeasureOnLoad = 1
IfTrueAction=[Play "Sounds\VLoad.WAV"]
UpdateDivider=-1

[MeasureOnLoad2]
Measure=Calc
Formula=Counter+5
IfCondition=MeasureOnLoad2 = 5
IFTrueAction=!ActivateConfig "UmbrellaAdvertisement" "GifFrames.ini"
ImageName=#@#ImagesFrames\SAMPLE - ([ImageNumberCalc]).png
IFTrueAction=MaxNumber = 5 ;seems to be slowing GiFFrames #1 to 5 second intervols
IFAboveValue=#MaxNumber#
FormulaCounter = % 86 
UpdateDivider=-1
Last edited by jsmorley on July 30th, 2019, 11:19 am, edited 1 time in total.
Reason: Use code tags for displaying code. It's the </> button
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3543
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Choosing a different Image depending on the time

eclectic-tech » July 31st, 2019, 10:57 am

Your first measure [MeasureOnLoad] will work.

Your second measure [MeasureOnLoad2] has multiple syntax errors and will not do what you want.
Review the COMMENTS in your code.

Code: Select all

[MeasureOnLoad2]
Measure=Calc

; COMMENT: Adding 5 to the Counter is not really needed, and will cause the "IfTrueAction=" to happen immediately
Formula=Counter + 5
IfCondition=MeasureOnLoad2 = 5
IFTrueAction=!ActivateConfig "UmbrellaAdvertisement" "GifFrames.ini"

; COMMENT: Measures do not support "ImageName=". This must be in an Image meter. 
ImageName=#@#ImagesFrames\SAMPLE - ([ImageNumberCalc]).png

; COMMENT: You can not have duplicate "IfTrueAction=" for a single "IfCondition=" 
; To test more values use "IfCondition2=" and "IfTrueAction2=" etc.
IFTrueAction=MaxNumber = 5 

; COMMENT: The overall skin speed is updated once per second, so it will run slow
;seems to be slowing GiFFrames #1 to 5 second intervols

; COMMENT: You have no action associated with the "IfAboveValue=" test ... ?
IFAboveValue=#MaxNumber#

; COMMENT: Not sure what this is? Did you mean "Formula=Counter % 86" ... 
; If so, you can not have duplicates in the same section (You already have a "Formula=" above)
FormulaCounter= % 86 

; COMMENT: This stops any update to this measure, so it will never check the value of "Counter" after the first update
UpdateDivider=-1
I would simplify the second measure as below and see if it loads your config after 5 seconds.
Then we can go from there.

Code: Select all

[MeasureOnLoad2]
Measure=Calc
Formula=Counter
IfCondition=MeasureOnLoad2 = 5
IFTrueAction=!ActivateConfig "UmbrellaAdvertisement" "GifFrames.ini"
User avatar
balala
Rainmeter Sage
Posts: 8626
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Choosing a different Image depending on the time

balala » July 31st, 2019, 3:27 pm

Vx_Lotus wrote:
July 30th, 2019, 7:58 am
This is my mess but i'm working with gifs... I tried to use the counter but I cant figure out rainmeters program structure... i'm just not used to it.
***wait 3 seconds then load another gif that plays once. or Load and play once emediately after .wav has ended***

[gif 1 = 36 frames, ;gif 2 = 86 frames.] :jawdrop
[gif 1 stays playing constantly (FUTURE COMPUTER ASSISTANT)] :o
[gif 2 plays once ] :uhuh:
[then when it closes I was going to load in a new cpu core image skin.. ]
[Right now click - 2 skins load, plays gif 1 but doesn't start gif 2 or play gif 2 after 5 seconds.] :confused:
[these 2 loads run off a main] :?

At this point I was thinking of starting over with these 2 and going about it a different way. :thumbdown:
The parent gif loads gif main() then gif Main() controls ----loading \unloading gifs\sounds\skins these below are supposed to be a small part of that sequence. My question is. If that code works for a picture or image, will it work with gifs? or is there a guaranteed way to do this? :???:
Beside eclectic-tech's reply note that Rainmeter can't play animated GIFs. It can show a not-animated GIF or if an animated GIF is used, it shows only the first frame of it. So I'm not sure how are you playing those GIFs.
User avatar
Vx_Lotus
Posts: 34
Joined: July 30th, 2019, 7:37 am

Re: Choosing a different Image depending on the time

Vx_Lotus » July 31st, 2019, 5:39 pm

Thank you both for the reply's.
Answer to number 1 = this is the test for, the test failed.

**Wait 5 seconds, Close frame sequence #2***

Code: Select all

IFTrueAction=MaxNumber = 5
FormulaCounter= + 1 ;seems to be slowing GiFFrames #1 to 5 second intervols
IFAboveValue=#MaxNumber#
FormulaCounter = % 86 
UpdateDivider=-1
IFTrueAction=!DisableConfig "UmbrellaAdvertisement" "GifFrames.ini"
Answer to number 2 = Rainmeter can play a .gif but you must break the set of images down individually. [A backdoor persay, or workaround]
; Note - You will need to get and install ImageMagick from:
; http://www.imagemagick.org/script/binary-releases.php
; Convert your .gif image to a "Bitmap" with the following in a cmd.exe command prompt window:
; convert -coalesce "C:\PathToInput\InputName.gif" "C:\PathToOutput\OutputName.png"
I used online converter to do this. and a video editor : OpenShot Editor (get sequence) : online converter (Convert .mp4 to .gif) : personal converter : (.gif to .png) file so you don't have to do the above exactly....
;snippet from one of my .gifs here as example.
(FILE 1)

Code: Select all

LeftMouseUpAction=[!ToggleConfig "TheRedQueen" "GifFrames.ini"] ;action that calls the below to work
(File 2)

Code: Select all

[MeasureOnLoad]
Measure=Calc
Formula=Counter
IfCondition=MeasureOnLoad = 1
IfTrueAction=[Play "C:\Users\Lotus\Documents\Rainmeter\Skins\TheRedQueen\Sounds\VLoad.WAV"]
UpdateDivider=-1

[MeasureOnLoad2]
Measure=Calc ;tells system to run a calculator
Formula=Counter ;tells the system to start counting
IfCondition=MeasureOnLoad = 1 ;add 1 on the counter
IFTrueAction=!ActivateConfig "UmbrellaAdvertisement" "GifFrames.ini" ;file location of the images
ImageName=#@#ImagesFrames\SAMPLE - ([ImageNumberCalc]).png ;Calculates the images in specified file

[Sidebar_Left] ;displays the images to screen
Meter=IMAGE
X=0
Y=0
W=100

[Rainmeter] ;refresh rate of image(S)
Update=100

[Metadata] ;unedited information snippet
Name=GIFFrames
Author=Rainmeter Team
Information=Displays a deconstructed .gif file (individual frames) as if it was a .gif file || Instructions: See .ini file for how to get and use ImageMagick
Version=Jan 16, 2016
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[ImageNumberCalc] ;runs calculator called above 
Measure=Calc ;adds to calculator
Formula=Counter % 39 ;counts 39.png frames harvested from the .gif

[ImageMeter] ;image size perameter
W=200
H=100

LeftMouseUpAction=!ToggleConfig "TheRedQueen" "GifFrames.ini" ;function
Meter=Image

;calls the first name of the file set in the folder and adds calculators = +1  (Simple - (1)) Simple - (2) ect…. 
;alt + a selects all images in the file, Rename the first while all selected changes all files to start with the name Simple;
;then the numbers are auto updated when the first image is given a number while all selected.
;([ImageNumberCalc]) calculates the number inside the () and adds it to the program sequence. calls location of the numbered image in           
;line and loops it back to the top Counter.

;ImageName = pulls image location
ImageName=#@#ImagesFrames\REDQUEEN - ([ImageNumberCalc]).png 
;AntiAlias=1 ;disables the +1 because the value is allready 1
DynamicVariables=1 
I will continue to work with the first reply to see if I get a better result \ functionality out of the sequence and go from there. Hopefully this helps
Mini-Boss.png
.gif break down.png
To make it as though the image doesn't flash during refresh, put a static image of the first frame behind the .gif images.
You do not have the required permissions to view the files attached to this post.
Last edited by Vx_Lotus on July 31st, 2019, 6:28 pm, edited 3 times in total.
User avatar
Vx_Lotus
Posts: 34
Joined: July 30th, 2019, 7:37 am

Re: Choosing a different Image depending on the time

Vx_Lotus » July 31st, 2019, 6:18 pm

Further answer to #1
I tested the code: Both .gifs load at the same time. (Test shows failure) I think the counter is wrong. But I don't know how to use it properly. What if we did; [cCounter] function? The idea was to loop the images to make the gif play on desktop. it does that. SO we needed to put a stop loop in to close the second one while resuming the first.
I ran a test using

Code: Select all

Formula=Counter+5
, I ran a value test

Code: Select all

IFTrueAction=MaxNumber = 5
test to see if it read the counter, and

Code: Select all

IFAboveValue=#MaxNumber#
, test to see if the value 5 had been set, nothing worked.

; COMMENT: Measures do not support "ImageName=". This must be in an Image meter.
ImageName=#@#ImagesFrames\SAMPLE - ([ImageNumberCalc]).png <on the contrary - The calculator seems to work inside the measure lol>


Code: Select all

[MeasureOnLoad]
Measure=Calc
Formula=Counter
IfCondition=MeasureOnLoad = 1
IfTrueAction=[Play "C:\Users\Lotus\Documents\Rainmeter\Skins\TheRedQueen\Sounds\VLoad.WAV"]
UpdateDivider=-1
;wait 3 seconds then load another gif that plays once. or Load and play once emediately after .wav has ended

Code: Select all

[MeasureOnLoad2]
Measure=Calc
Formula=Counter
IfCondition=MeasureOnLoad2 = 5
IFTrueAction=!ActivateConfig "UmbrellaAdvertisement" "GifFrames.ini"
ImageName=#@#ImagesFrames\SAMPLE - ([ImageNumberCalc]).png
;sets the value to play once (HOPEFULLY ;O)

Code: Select all

IFAboveAction=[!DisableConfig "UmbrellaAdvertisement" "GifFrames.ini"]