It is currently March 28th, 2024, 3:20 pm

Help! Cycle through rainmeter layouts periodically

Get help with installing and using Rainmeter.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Help! Cycle through rainmeter layouts periodically

Post by mak_kawa »

Hi QuantaNeon

This is my last solution...:-) I have tested actually !LoadLayout bang on my Rainmeter, and confirmed that it works well at least for me. But honestly, I am not confident. Maybe, there are some correct/smart solutions from other members... it's my limitation on Rainmeter skill. Now I gave up, sorry.

Code: Select all

[Rainmeter]
Update=1000

[Variables]
OnRefresh=1
MaxLayout=6
MyLayout1=(Your Layout Name 1)
MyLayout2=(Your Layout Name 2)
MyLayout3=(Your Layout Name 3)
MyLayout4=(Your Layout Name 4)
MyLayout5=(Your Layout Name 5)
MyLayout6=(Your Layout Name 6)
LayoutChangeInterval=3600
SecondsAfterRefresh=0
@Include=Settings.inc

[MeasureSecondsAfterRefresh]
Measure=Calc
Formula=1
OnUpdateAction=[!SetVariable SecondsAfterRefresh (#SecondsAfterRefresh#+1)]
IfCondition=((#SecondsAfterRefresh#%#LayoutChangeInterval#)=0) && (#OnRefresh#=0)
IfTrueAction=[!WriteKeyValue Variables Layout (#Layout#+1) Settings.inc][!SetVariable Layout (#Layout#+1)][!EnableMeasure LayoutChange][!UpdateMeasure LayoutChange]
IfCondition2=(#OnRefresh#=1)
IfTrueAction2=[!SetVariable OnRefresh 0]
DynamicVariables=1

[LayoutChange]
Measure=Calc
Formula=1
IfConditionMode=1
IfCondition=(#Layout#>#MaxLayout#)
IfTrueAction=[!WriteKeyValue Variables Layout 1 Settings.inc][!SetVariable Layout 1][!LoadLayout #MyLayout1#]
IfFalseAction=[!LoadLayout [#MyLayout[#Layout]]]
DynamicVariables=1
UpdateDivider=-1
Disabled=1

[meterDummy]
Meter=String
Settings.inc:

Code: Select all

[Variables]
Layout=1
User avatar
Yincognito
Rainmeter Sage
Posts: 7023
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help! Cycle through rainmeter layouts periodically

Post by Yincognito »

QuantaNeon wrote: August 16th, 2020, 9:55 amHi! I have a set of layouts designed by me, and i want those layouts to change automatically, for example, every hour, how can i do that??
Here's how:

- first, you will need to make a skin called, say, LayoutChanger.ini (can be created in a folder having the same name, in order to be "consistent" about things) and paste the code below in its .INI. Take a look here on how to create a new skin (skip the template stuff and just go for the folder and file stuff), or, if you already know how to do it manually, you can use that approach as well.

- secondly, you will need to save your created layouts as Layout0, Layout1, Layout2,...Layout5 (if you have 6 layouts, that is - if you have more or less just name them from 0 to NumberOfLayouts-1), but, very important, include the LayoutChanger.ini skin mentioned above in each of those saved layouts. The skin will not be visible as it's only meant to change layouts periodically, but it's paramount to have it loaded in those layouts in order for the layout change to happen in the first place. Take a look here for details on how to save your layouts - just check Exclude Unloaded Skins and save each layout (with the LayoutChanger.ini skin mentioned above loaded at the time of saving, obviously) as mentioned above and that's it.

LayoutChanger.ini code:

Code: Select all

[Variables]
LayoutChangeInterval=3600
LayoutCount=6
ActiveLayoutIndex=0

[Rainmeter]
Update=1000

[MeasureNextLayoutIndex]
Measure=Calc
Formula=((#ActiveLayoutIndex#+1)%#LayoutCount#)
UpdateDivider=-1

[MeasureCounter]
Measure=Calc
Formula=(MeasureCounter+1)
IfCondition=(MeasureCounter>#LayoutChangeInterval#)
IfTrueAction=[!WriteKeyValue Variables ActiveLayoutIndex "[MeasureNextLayoutIndex]"][!LoadLayout "Layout[MeasureNextLayoutIndex]"]
IfConditionMode=1

[MeterDummy]
Meter=String
You can control things by modifying the self-explanatory variables in the [Variables] section, if needed. For example, to see if it works you can reduce the LayoutChangeInterval value to, say, 30 (seconds) and check if the layout iteration is happening properly. This works without any kind of issues for me, so, assuming you've done everything appropriately, it should work for you as well.

P.S. Obviously, the name of the skin can be different, if you like - I just mentioned it that way to give you an idea on how to achieve what you want.
P.S.S. To stop the layout iteration all you need to do is unload the skin above, or, if you only want to pause the iteration, add a Paused=1 line to [MeasureCounter] above. More about the Paused option here.
Post Reply