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

Changing wallpaper with time

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Changing wallpaper with time

Post by Yincognito »

zaxnite wrote: November 1st, 2020, 4:56 pm

Code: Select all

IfCondition3=(MeasureTime > 2000 ) && (MeasureTime < 0600)
IfTrueAction3=!SetWallpaper "3.jpg"
This will never work. If it's 9 PM, for example, i.e. 2100, then 2100>2000 ... but 2100 is NOT less than 0600. You'd better base this on the number of seconds in the day that have passed instead (or modify the IfCondition to ((MeasureTime > 2000 ) && (MeasureTime < 2359)) || ((MeasureTime > 0000 ) && (MeasureTime < 0600))). Oh, and also, set your update to 1000 ms. No point updating this one tenth of a second, like you do now through Update=100, because Rainmeter can't measure time under the second anyway.

By the way, && means logical AND, while || means logical OR above.

P.S. Optionally, you might want to cover the equality with the bounds case, saying for example:
((MeasureTime >= 2000 ) && (MeasureTime < 2359)) || ((MeasureTime >= 0000 ) && (MeasureTime < 0600))
That goes for the other if conditions as well.
Last edited by Yincognito on November 1st, 2020, 5:44 pm, edited 2 times in total.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing wallpaper with time

Post by jsmorley »

Wouldn't this work?

Code: Select all

IfCondition3=(MeasureTime > 2000 ) || (MeasureTime < 0600)
IfTrueAction3=!SetWallpaper "3.jpg"
Using "OR" instead of "AND"?

Edit... Beat me to it.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Changing wallpaper with time

Post by balala »

EDIT: Well, Yincognito and jsmorley beat me, however take into account the rest of my recommendations, except the first one (which is exactly what they also said).
zaxnite wrote: November 1st, 2020, 4:56 pm still shows only the first one
Note a few things related to the code:
  • There is no valid conditon in case the time is either 6:00, 14:30, 19:59 or 20:00. I'd include some equalities beside the inequalities inot the IfConditions.
  • IfCondition3 is never met. While the time can be between 6:00 and 14:30 or between 14:30 and 20:00, it can't be greater then 20:00 AND smaller then 6:00. So the && operator of the IfCondition3 option should be ||, which leads IfCondition3 to be true between 20:00 and 6:00.
  • [MeasureEqual] is not needed. You can add the IfConditions directly to the [MeasureTime] measure. I added them so and rewrote the MeasureTime measure name into the IfCondition as #CURRENTSECTION#. If we're using the conditions on the [MeasureTime] measure, #CURRENTSECTION# is equal to MeasureTime and can beused into the Ifconditions this way.
  • Doesn't worth to update the skin ten times per second. Replace the Update=100 option of the [Rainmeter] section with the default Update=1000.
  • I'd add a # character into the Format option of the [MeasureTime], to the hour, to avoid the leading zeros. I modified the IfCondition options accordingly.
With the above modification the code look like this (and it does work for me):

Code: Select all

[Metadata]
Name=BG Changer Time
Author=Thiena
Information=
Version=1.0
License=What's This

[Rainmeter]
Update=1000
Group=NONE

[MeasureTime]
Measure=Time
Format=%#H%M
IfCondition=((#CURRENTSECTION# > 600 ) && (#CURRENTSECTION# <= 1430 ))
IfTrueAction=[!SetWallpaper "1.jpg"]
IfCondition2=((#CURRENTSECTION# > 1430 ) && (#CURRENTSECTION# <= 2000))
IfTrueAction2=[!SetWallpaper "2.jpg"]
IfCondition3=((#CURRENTSECTION# > 2000 ) || (#CURRENTSECTION# <= 600))
IfTrueAction3=[!SetWallpaper "3.jpg"]

[MeterTestImage]
Meter=Image
Imagename=""
User avatar
Yincognito
Rainmeter Sage
Posts: 7030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Changing wallpaper with time

Post by Yincognito »

jsmorley wrote: November 1st, 2020, 5:41 pm Wouldn't this work?

Code: Select all

IfCondition3=(MeasureTime > 2000 ) || (MeasureTime < 0600)
IfTrueAction3=!SetWallpaper "3.jpg"
Using "OR" instead of "AND"?

Edit... Beat me to it.
I think it will, as far as I can see - and it's much simpler. :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing wallpaper with time

Post by jsmorley »

balala wrote: November 1st, 2020, 5:42 pm EDIT: Well, Yincognito and jsmorley beat me...


Note a few things related to the code:
  • There is no valid conditon in case the time is either 6:00, 14:30, 19:59 or 20:00. I'd include some equalities beside the inequalities inot the IfConditions.
  • IfCondition3 is never met. While the time can be between 6:00 and 14:30 or between 14:30 and 20:00, it can't be greater then 20:00 AND smaller then 6:00. So the && operator of the IfCondition3 option should be ||, which leads IfCondition3 to be true between 20:00 and 6:00.
  • [MeasureEqual] is not needed. You can add the IfConditions directly to the [MeasureTime] measure. I added them so and rewrote the MeasureTime measure name into the IfCondition as #CURRENTSECTION#. If we're using the conditions on the [MeasureTime] measure, #CURRENTSECTION# is equal to MeasureTime and can beused into the Ifconditions this way.
  • Doesn't worth to update the skin ten times per second. Replace the Update=100 option of the [Rainmeter] section with the default Update=1000.
  • I'd add a # character into the Format option of the [MeasureTime], to the hour, to avoid the leading zeros. I modified the IfCondition options accordingly.
With the above modification the code look like this (and it does work for me):

Code: Select all

[Metadata]
Name=BG Changer Time
Author=Thiena
Information=
Version=1.0
License=What's This

[Rainmeter]
Update=1000
Group=NONE

[MeasureTime]
Measure=Time
Format=%#H%M
IfCondition=((#CURRENTSECTION# > 600 ) && (#CURRENTSECTION# <= 1430 ))
IfTrueAction=[!SetWallpaper "1.jpg"]
IfCondition2=((#CURRENTSECTION# > 1430 ) && (#CURRENTSECTION# <= 2000))
IfTrueAction2=[!SetWallpaper "2.jpg"]
IfCondition3=((#CURRENTSECTION# > 2000 ) || (#CURRENTSECTION# <= 600))
IfTrueAction3=[!SetWallpaper "3.jpg"]

[MeterTestImage]
Meter=Image
Imagename=""
I believe this to be the correct answer. While I think using #CURRENTSECTION# might be a bit pointless, and only adds a tiny, tiny amount of extra work to resolve the variable, the rest of it is how I would go. While it's not important, I agree in principle with not allowing the leading zeros on the hour, as technically speaking, there is no such number as 0600. Rainmeter will ignore the leading zero when used in math, but it's cleaner this way...
zaxnite
Posts: 13
Joined: November 1st, 2020, 4:37 pm

Re: Changing wallpaper with time

Post by zaxnite »

ohh okay but it still doesnt change to third one :/
Last edited by zaxnite on November 1st, 2020, 6:01 pm, edited 2 times in total.
User avatar
Yincognito
Rainmeter Sage
Posts: 7030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Changing wallpaper with time

Post by Yincognito »

zaxnite wrote: November 1st, 2020, 5:49 pm ohh okay but it still doesnt change to third one :/
Are you sure you're not living at one of the poles, where there is no night for 6 months? :D
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing wallpaper with time

Post by jsmorley »

zaxnite wrote: November 1st, 2020, 5:49 pm ohh okay but it still doesnt change to third one :/
I think you will find that if you use exactly this:

Code: Select all

[MeasureTime]
Measure=Time
Format=%#H%M
IfCondition=((#CURRENTSECTION# > 600 ) && (#CURRENTSECTION# <= 1430 ))
IfTrueAction=[!SetWallpaper "1.jpg"]
IfCondition2=((#CURRENTSECTION# > 1430 ) && (#CURRENTSECTION# <= 2000))
IfTrueAction2=[!SetWallpaper "2.jpg"]
IfCondition3=((#CURRENTSECTION# > 2000 ) || (#CURRENTSECTION# <= 600))
IfTrueAction3=[!SetWallpaper "3.jpg"]
That it will in fact work properly.

You can test by changing Format=%#H%M to

Format=700
Format=1500
Format=2100 or Format=500

And refreshing the skin. It will change from 1 to 2 to 3 properly. That assumes that you actually have all three images where you think you do.
zaxnite
Posts: 13
Joined: November 1st, 2020, 4:37 pm

Re: Changing wallpaper with time

Post by zaxnite »

I got it thank you so much
User avatar
Yincognito
Rainmeter Sage
Posts: 7030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Changing wallpaper with time

Post by Yincognito »

jsmorley wrote: November 1st, 2020, 5:56 pm I think you will find that if you use exactly this:

Code: Select all

[MeasureTime]
Measure=Time
Format=%#H%M
IfCondition=((#CURRENTSECTION# > 600 ) && (#CURRENTSECTION# <= 1430 ))
IfTrueAction=[!SetWallpaper "1.jpg"]
IfCondition2=((#CURRENTSECTION# > 1430 ) && (#CURRENTSECTION# <= 2000))
IfTrueAction2=[!SetWallpaper "2.jpg"]
IfCondition3=((#CURRENTSECTION# > 2000 ) || (#CURRENTSECTION# <= 600))
IfTrueAction3=[!SetWallpaper "3.jpg"]
That it will in fact work properly.

You can test by changing Format=%#H%M to

Format=700
Format=1500
Format=2100 or Format=500

And refreshing the skin. It will change from 1 to 2 to 3 properly. That assumes that you actually have all three images where you think you do.
Actually, it won't, from an expected behavior point of view - and I think that was the problem. I just tested (got past 20:00 locally just now), and it didn't change the wallpaper immediately ... because it waited for a whole minute to do it. I think this might have been the issue in the first place, that's why I suggested approaching this based on the number of seconds in the day that passed.

That being said, it's not a tragedy, just a bit of delay, according to the code.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth