It is currently April 28th, 2024, 2:44 pm

Toggle meter help

Get help with creating, editing & fixing problems with skins
RicardoTM
Posts: 269
Joined: December 28th, 2022, 9:30 pm
Location: México

Toggle meter help

Post by RicardoTM »

Hey, I want to toggle a meter on one config from another.

Well, !ToggleMeter works fine.

The problem is that as soon as the config is refreshed the meter re-appears.

I want it to be "permanent" until I toggle it again, is that possible?

Thanks.
User avatar
Yincognito
Rainmeter Sage
Posts: 7179
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Toggle meter help

Post by Yincognito »

RicardoTM wrote: November 30th, 2023, 11:21 am Hey, I want to toggle a meter on one config from another.

Well, !ToggleMeter works fine.

The problem is that as soon as the config is refreshed the meter re-appears.

I want it to be "permanent" until I toggle it again, is that possible?

Thanks.
Hello again,

Yes, it is - just store the meter's state (0 or 1, I suppose) in a variable in the controlled skin. Then, either !WriteKeyValue the corresponding value to the variable, from the controlling config when toggling, or, to avoid writing to file every time you toggle the meter from the controlling skin, just use OnCloseAction in the [Rainmeter] section of the controlled skin to do the same. The latter works on closing, but although it logically should since refresh is just closing and reopening, not sure if it works on refreshing.

P.S. In case it wasn't obvious, the aforementioned variable should be used as the initial value of the desired state / option in the meter from the controlled skin, for the latter to load or refresh with the previously stored / written value for that state.

EDIT: It's possible that the controlling skin should be aware of the current value of the meter's state too, so that it knows what to write in the controlled skin. This can be normally be achieved by @including the same .inc file storing the state variable's value in both configs.

EDIT2: Example - now !ToggleMeter isn't even necessary, since we can use the state from the variable (middle click = toggle config, left click = toggle meter, both from Test1.ini, but you can manually refresh Test2.ini and see how it goes; be aware that the variable value is remembered even if Test2.ini isn't loaded at the time of its meter toggling)...

...\@Resources\Variables.inc:

Code: Select all

[Variables]
State=0
...\Test1.ini (the controlling config / skin):

Code: Select all

[Variables]
@IncludeVariables=#@#Variables.inc

[Back]
Meter=Image
W=100
H=100
SolidColor=0,0,255,255
LeftMouseUpAction=[!SetVariable State (1-#State#)][!SetVariable State (1-#State#) "Tests\Test2"][!UpdateMeter *][!UpdateMeter * "Tests\Test2"][!Redraw "Tests\Test2"][!WriteKeyValue Variables State (1-#State#) "#@#Variables.inc"]
MiddleMouseUpAction=[!ToggleConfig "Tests\Test2" "Test2.ini"]
DynamicVariables=1
...\Test2.ini (the controlled config / skin):

Code: Select all

[Variables]
@IncludeVariables=#@#Variables.inc

[Back]
Meter=Image
W=100
H=100
SolidColor=0,255,0,255

[Toggled]
Hidden=#State#
Meter=Image
W=50
H=50
SolidColor=255,0,0,255
DynamicVariables=1
As I suspected, using OnCloseAction to trigger the !WriteKeyValue on refreshing the controlled config / skin didn't work. I think I posted a "bug" (not really) report on this in the past... ah, here it is. It would have helped here to avoid writing stuff to file on every mouse click and only do it when the skin closes (including on refresh), but given Brian's explanation in the other thread, we can't do that... :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RicardoTM
Posts: 269
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Toggle meter help

Post by RicardoTM »

Yincognito wrote: November 30th, 2023, 2:25 pm Hello again,

Yes, it is - just store the meter's state (0 or 1, I suppose) in a variable in the controlled skin. Then, either !WriteKeyValue the corresponding value to the variable, from the controlling config when toggling, or, to avoid writing to file every time you toggle the meter from the controlling skin, just use OnCloseAction in the [Rainmeter] section of the controlled skin to do the same. The latter works on closing, but although it logically should since refresh is just closing and reopening, not sure if it works on refreshing.

P.S. In case it wasn't obvious, the aforementioned variable should be used as the initial value of the desired state / option in the meter from the controlled skin, for the latter to load or refresh with the previously stored / written value for that state.

EDIT: It's possible that the controlling skin should be aware of the current value of the meter's state too, so that it knows what to write in the controlled skin. This can be normally be achieved by @including the same .inc file storing the state variable's value in both configs.

EDIT2: Example - now !ToggleMeter isn't even necessary, since we can use the state from the variable (middle click = toggle config, left click = toggle meter, both from Test1.ini, but you can manually refresh Test2.ini and see how it goes; be aware that the variable value is remembered even if Test2.ini isn't loaded at the time of its meter toggling)...

...\@Resources\Variables.inc:

Code: Select all

[Variables]
State=0
...\Test1.ini (the controlling config / skin):

Code: Select all

[Variables]
@IncludeVariables=#@#Variables.inc

[Back]
Meter=Image
W=100
H=100
SolidColor=0,0,255,255
LeftMouseUpAction=[!SetVariable State (1-#State#)][!SetVariable State (1-#State#) "Tests\Test2"][!UpdateMeter *][!UpdateMeter * "Tests\Test2"][!Redraw "Tests\Test2"][!WriteKeyValue Variables State (1-#State#) "#@#Variables.inc"]
MiddleMouseUpAction=[!ToggleConfig "Tests\Test2" "Test2.ini"]
DynamicVariables=1
...\Test2.ini (the controlled config / skin):

Code: Select all

[Variables]
@IncludeVariables=#@#Variables.inc

[Back]
Meter=Image
W=100
H=100
SolidColor=0,255,0,255

[Toggled]
Hidden=#State#
Meter=Image
W=50
H=50
SolidColor=255,0,0,255
DynamicVariables=1
As I suspected, using OnCloseAction to trigger the !WriteKeyValue on refreshing the controlled config / skin didn't work. I think I posted a "bug" (not really) report on this in the past... ah, here it is. It would have helped here to avoid writing stuff to file on every mouse click and only do it when the skin closes (including on refresh), but given Brian's explanation in the other thread, we can't do that... :confused:
Hey again,

This worked great. thank you very much. When I was trying to use !WriteKeyValue I was overcomplicating again lol, I don't know how (1-#variable#) didn't cross my mind at all. It was late I guess... I tried all sort of things lol
User avatar
Yincognito
Rainmeter Sage
Posts: 7179
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Toggle meter help

Post by Yincognito »

RicardoTM wrote: November 30th, 2023, 7:28 pm Hey again,

This worked great. thank you very much. When I was trying to use !WriteKeyValue I was overcomplicating again lol, I don't know how (1-#variable#) didn't cross my mind at all. It was late I guess... I tried all sort of things lol
No worries - the final outcome is what's most important. The path to get there is just a way to learn. :D
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RicardoTM
Posts: 269
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Toggle meter help

Post by RicardoTM »

Yincognito wrote: November 30th, 2023, 8:45 pm No worries - the final outcome is what's most important. The path to get there is just a way to learn. :D
Speaking of learning, one last question. What are the * for? What do they do/Indicate?

[!SetVariable State (1-#State#)][!SetVariable State (1-#State#) "Tests\Test2"][!UpdateMeter *][!UpdateMeter * "Tests\Test2"][!Redraw "Tests\Test2"][!WriteKeyValue Variables State (1-#State#) "#@#Variables.inc"]
User avatar
Yincognito
Rainmeter Sage
Posts: 7179
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Toggle meter help

Post by Yincognito »

RicardoTM wrote: November 30th, 2023, 8:49 pm Speaking of learning, one last question. What are the * for? What do they do/Indicate?
They basically mean "all". They can be used in most non-specific bangs - see the note at the top of the Bangs page from the manual:
https://docs.rainmeter.net/manual/bangs/
In this case, it means "all meters", since the bang is meter related.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RicardoTM
Posts: 269
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Toggle meter help

Post by RicardoTM »

Yincognito wrote: November 30th, 2023, 8:57 pm They basically mean "all". They can be used in most non-specific bangs - see the note at the top of the Bangs page from the manual:
https://docs.rainmeter.net/manual/bangs/
In this case, it means "all meters", since the bang is meter related.
Oh, that makes sense. Thank you!
User avatar
Yincognito
Rainmeter Sage
Posts: 7179
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Toggle meter help

Post by Yincognito »

RicardoTM wrote: November 30th, 2023, 9:41 pm Oh, that makes sense. Thank you!
:thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth