It is currently April 26th, 2024, 7:30 pm

[FEATURE] OnChangeStringAction vs OnChangeNumberValue

Report bugs with the Rainmeter application and suggest features.
User avatar
Yincognito
Rainmeter Sage
Posts: 7174
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

[FEATURE] OnChangeStringAction vs OnChangeNumberValue

Post by Yincognito »

This is related to this bug report here. For measures having different string and number values, you sometimes want the OnChangeAction to trigger only when one (and not when any) of those values changes. Example (related to the mentioned bug report, but can be extended to other measures having different number and string values):

Code: Select all

[MeasureWin7Audio]
Measure=Plugin
Plugin=Win7AudioPlugin
OnChangeAction=[!Refresh]
This provides the current / default output audio device name as its string value and that device's audio volume as its number value. You'd want the refresh bang to happen only when the device changes and not when you change or set the volume.

I know this can be achieved with an IfMatch / IfCondition as well, but it requires saving the previous value and if we have the OnChangeAction option, why not use it? Not sure about how to internally differentiate between strings and numbers since, if I'm not mistaken, I recall reading somewhere that everything is a string in Rainmeter, or regarding the naming convention for the "other choice", but that is up to the developers (maybe an additional option like OnChangeTarget being 0 for any value which would be the default, 1 for the numerical value and 2 for the string value, or something along these lines)...

UPDATE: Just realized that this can be easily achieved by using the string value of this measure in a subsequent String (or Calc and using the numerical value, if that value is the target) measure and moving the OnChangeAction option there, like:

Code: Select all

[MeasureWin7AudioString]
Measure=String
String=[MS_Win7Audio_Win7AudioDevice]
OnChangeAction=[!Refresh]
DynamicVariables=1
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
deflore08
Posts: 209
Joined: July 12th, 2020, 7:47 am
Location: Ada, Garden City

Re: [FEATURE] OnChangeStringAction vs OnChangeNumberValue

Post by deflore08 »

:lol:
I though to reach this by storing in variable and call comparing function. :? Really easy. :))) Thanks.
Image * Image * Image * Image
User avatar
Yincognito
Rainmeter Sage
Posts: 7174
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [FEATURE] OnChangeStringAction vs OnChangeNumberValue

Post by Yincognito »

deflore08 wrote: February 22nd, 2022, 10:07 am :lol:
I though to reach this by storing in variable and call comparing function. :? Really easy. :))) Thanks.
Yeah, storing the previous value is one way to do it. I didn't realized I could do the test in a subsequent suited measure using the same OnChangeAction at the time of posting though, so the feature suggestion became pointless after having that second thought about it. :D
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth