I've been trying to modify a skin that I downloaded. Basically, it reads the volume of the computer and puts it on a scale thing. Right now, all of it is working fine exceot when it is muted, it displays the volume as -1%, and I have been trying to program it so that when it is at "-1%', it changes it to 0% but to no success.
I've tried many different ways, but the latest attempt is in the variable section of [PercentageCalc]. Any help please? Thanks!
Here is one way to accomplish that...modified IfCondition actions in [PercentageCalc] section to change the 'Text' value of the string meter to 0% when the sound is muted; when [MeasureWin7Audio] = -1
ItsJustRyan wrote: ↑October 25th, 2019, 1:25 am
I've tried many different ways, but the latest attempt is in the variable section of [PercentageCalc]. Any help please? Thanks!
Besides eclectic-tech's solution note that there are a few errors in the original code:
In Rainmeter you can't define a variable as you do in programing languages. I mean that the x=(MeasureWin7Audio) option of the [PercentageCalc] measure isn't valide, you can't use it (not being a valid Rainmeter option) and you can't use later the x variable (for instance in the Formula or IfCondition options of the same measure). A "variable" section of a measure doesn't exist.
You can't use two IfCondition / IfTrueAction options on a single measure. You have to number them. This means that if would be valid, the second IfCondition / IfTrueAction should be IfCondition2 / IfTrueAction2:
IfCondition=x < 0
IfTrueAction=[!SetVariable x "0"]
IfCondition2=x>0
IfTrueAction2=[!SetVariable x "MeasureWin7Audio"]
I also propose another solution behind eclectic-tech's measure. You could use the following [PercentageCalc] measure, instead of eclectic-tech's one, which makes the IfCondition useless:
I've had that issue for years lol but ignored it as I never really use the Mute.
I thought you could just use Substitute="-1":"MUTED" or something similar?
sl23 wrote: ↑October 30th, 2019, 11:28 pm
I've had that issue for years lol but ignored it as I never really use the Mute.
I thought you could just use Substitute="-1":"MUTED" or something similar?
A measure has 2 values NUMBER and STRING; substitution only affects the STRING value, the NUMBER value is not changed by substitution. It depends on where you are using the measure value that determines what method to use.
In the case of Win7AudioPlugin, the STRING value is the current sound device name, while the NUMBER value is the current volume level. You are dealing with 2 completely different values.
Substitute="-1":"MUTED" will not work because the STRING value (that substitution affects) will never be "-1".
One way to deal with this could be to use an IfCondition action to test the NUMBER value of the measure and change your display meter to "Muted" when the value is "-1".
eclectic-tech wrote: ↑November 9th, 2019, 2:12 am
A measure has 2 values NUMBER and STRING; substitution only affects the STRING value, the NUMBER value is not changed by substitution. It depends on where you are using the measure value that determines what method to use.
In the case of Win7AudioPlugin, the STRING value is the current sound device name, while the NUMBER value is the current volume level. You are dealing with 2 completely different values.
Substitute="-1":"MUTED" will not work because the STRING value (that substitution affects) will never be "-1".
One way to deal with this could be to use an IfCondition action to test the NUMBER value of the measure and change your display meter to "Muted" when the value is "-1".
Even if not obvious, it can be done even with substitution, but there has to be added a String measure:
[MeasureVolumeS] gets the volume level returned by [MeasureVolume] as a string, makes the substitution (if needed, so if the system is muted) and returns either the volume level (if the system isn't muted), or Muted (if it is).
So as you can see, it can be done, however question is if it does worth. Probably not.
Two additional comments related to eclectic-tech's code:
If you hide / show meters, there is not needed to update them. Redrawing the skin is completely enough. That's why I'd remove the [!UpdateMeter *] bang from the IfTrueActin and IfFalseAction options of the [MeasureVolume] measure.
Instead of having two distinct meters ([Volume] and [Muted]), I'd better use one single and would set its Text option with !SetOption bangs. Just to reduce the number of sections, because the less meters we have, the better is.
This performs exactly as before. I then realised I forgot to change [VolLevel] Text=[mVolume:] to Text=msVolume. This now displays msVolume instead of the numerical volume as before. What's wrong?
sl23 wrote: ↑November 9th, 2019, 7:17 pm
This now displays msVolume instead of the numerical volume as before. What's wrong?
When you want to show the value returned by a measure (this time by [msVolume]), don't put the Text=msVolume option, because this shows msVolume, as you saw. Instead add a MeasureName=msVolume option, along with Text=%1. This way the String meter shows the value returned by the [msVolume] measure. And one more: this procedure doesn1t require to set the dynamic variables, so you can remove the DynamicVariables=1 option as well.