It is currently March 28th, 2024, 6:35 pm

Problem with writing variables from a skin to another.

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Problem with writing variables from a skin to another.

Post by kyriakos876 »

I have a skin named Skin1.ini and another named Skin2.ini
I have a Meter in Skin1.ini that, when clicked, writes a Variable in the Skin2.ini.
The problem is that Skin2.ini doesn't get the new variable until a [!Refresh] is executed.
I want it to get the variable when an [!Update] is executed as well, so that I don't have to Refresh the whole skin every time the variables changes.

As always,
Thanks in advance.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Problem with writing variables from a skin to another.

Post by jsmorley »

kyriakos876 wrote:I have a skin named Skin1.ini and another named Skin2.ini
I have a Meter in Skin1.ini that, when clicked, writes a Variable in the Skin2.ini.
The problem is that Skin2.ini doesn't get the new variable until a [!Refresh] is executed.
I want it to get the variable when an [!Update] is executed as well, so that I don't have to Refresh the whole skin every time the variables changes.

As always,
Thanks in advance.
Nope. Physical changes to a skin .ini file will only be read when the skin is loaded or refreshed.

What you will have to do is use both the !WriteKeyValue bang to permanently change the .ini file, and at the same time use [!SetVariable VarName "VarValue" "ConfigName"] to dynamically set the variable value in the second skin.

https://docs.rainmeter.net/manual/skins/#Config
https://docs.rainmeter.net/manual/bangs/
Note: Many bangs have a Config parameter. Unless otherwise specified, valid values are the config name of a currently loaded skin to be acted upon or * (asterisk) to act on all currently loaded skins. When optional and not supplied, the parameter defaults to the current config.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Problem with writing variables from a skin to another.

Post by balala »

Sorry jsmorley, I was late a bit...
kyriakos876 wrote:I have a skin named Skin1.ini and another named Skin2.ini
I have a Meter in Skin1.ini that, when clicked, writes a Variable in the Skin2.ini.
The problem is that Skin2.ini doesn't get the new variable until a [!Refresh] is executed.
I want it to get the variable when an [!Update] is executed as well, so that I don't have to Refresh the whole skin every time the variables changes.
If you write the variable to Skin2.ini, with a !WriteKeyValue bang, it can't use it, until a refresh isn't done. Instead of writing it, or beside this operation, you also should use a !SetVariable, to can dynamically use the new value of that variable. I mean something like: LeftMouseUpAction=[!WriteKeyValue Variables TheNameOfVar "TheNewVal" "TheConfigOfSkin2"][!SetVariable TheNameOfVar "TheNewVal" "TheConfigOfSkin2"]. With this option, when the appropriate meter of Skin1 (which has set the above LeftMouseUpAction) is clicked, two things will happen: the value of the TheNameOfVar variable will be written into the [Variables] section of Skin2.ini and in paralel the same value will be dynamically set to that variable. This way, Skin2.ini will be able to use it. If you just write the value, the refresh is absolutely required, otherwise the skin can't use the newly written value of the variable.
Note that almost every bang has a Config (in most cases not used) parameter, which indicates to which config is applied that bang. Also don't forget to add the DynamicVariables=1 option to each meter or measure of the Skin2.ini, which should use the new value of the variable.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Problem with writing variables from a skin to another.

Post by kyriakos876 »

Thank you both. You suggestion worked exactly as I wanted!
Post Reply