It is currently August 8th, 2020, 9:42 am

Help in programming

Help with creating, editing & fixing problems with skins
User avatar
sl23
Posts: 411
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Help in programming

Post by sl23 »

Oh yeah, lol, what a din! I didn't notice the change there! It's because at first I had Text=[mVolume:] so I changed the last part by adding the 's' which didn't work. Then removed the [] and : which also didn't work. Now I know why!

Thanks Balala :thumbup:
User avatar
sl23
Posts: 411
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Help in programming

Post by sl23 »

Oh dear! It's broken other controls for Volume! MouseScroll and Left/Right click change the Bar but not the numerical value.

How do I know which Measure to use? Now that you've changed it.

This is all the Volume sections of the skin:

Code: Select all

[Rainmeter]
Update=25
BackgroundMode=2
SolidColor=0,0,0,1
SkinHeight=39
DynamicWindowSize=1
AccurateText=1
LeftMouseUpAction=[!ToggleMeter sTime][!ToggleMeter Time][!Redraw]
MouseOverAction=[!ShowMeterGroup Hover] [!UpdateMeterGroup *] [!SetOption VolLevel FontColor "128,255,0"] [!UpdateMeter *] [!Redraw]
MouseLeaveAction=[!HideMeterGroup Hover] [!UpdateMeterGroup *] [!SetOption VolLevel FontColor "175,175,175"] [!UpdateMeter *] [!Redraw]
MouseScrollUpAction=[!CommandMeasure "mVolume" "ChangeVolume 5"] [!UpdateMeasure mVolume] [!UpdateMeter VolBar] [!UpdateMeasure mVolume] [!UpdateMeter *] [!Redraw]
MouseScrollDownAction=[!CommandMeasure "mVolume" "ChangeVolume -5"] [!UpdateMeasure mVolume] [!UpdateMeter VolBar] [!UpdateMeasure mVolume] [!UpdateMeter *] [!Redraw]
MiddleMouseUpAction=[!CommandMeasure "mVolume" "ToggleMute"] [!UpdateMeasure mVolume] [!UpdateMeter VolBar] [!UpdateMeasure mVolume] [!UpdateMeter *] [!Redraw]

[Variables]
VolLow=25
VolMax=80

========================================
; VOLUME
========================================
[mVolume]
Measure=Plugin
Plugin=Win7AudioPlugin

[msVolume]
Measure=String
String=[mVolume:]
UpdateDivider=#UD1#
Substitute="-1":"MUTED"

[VolLevel]
Meter=String
MeasureName=msVolume
FontFace=Corbel
StringStyle=Bold
FontSize=12
FontColor=175,175,175
SolidColor=0,0,0,1
Text=%1
AntiAlias=1
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure "mVolume" "SetVolume #VolLow#"] [!UpdateMeasure mVolume] [!UpdateMeter *] [!Redraw]
RightMouseUpAction=[!CommandMeasure "mVolume" "SetVolume #VolMax#"] [!UpdateMeasure mVolume] [!UpdateMeter *] [!Redraw]
MiddleMouseUpAction=ms-settings:sound
X=2
Y=15

[VolBar]
Meter=Bar
MeasureName=mVolume
BarColor=255,128,0
SolidColor=60,60,60
LeftMouseUpAction=[!SetOption mVolume Formula "($MouseX:%$)"] [!UpdateMeasure mVolume] [!CommandMeasure "mVolume" "SetVolume [mVolume]"] [!UpdateMeasure mVolume] [!UpdateMeter *] [!Redraw]
BarOrientation=Horizontal
DynamicVariables=1
Hidden=1
Group=Hover
Y=36
W=180
H=2
User avatar
balala
Rainmeter Sage
Posts: 11172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help in programming

Post by balala »

sl23 wrote:
November 9th, 2019, 7:58 pm
It's because at first I had Text=[mVolume:] so I changed the last part by adding the 's' which didn't work. Then removed the [] and : which also didn't work. Now I know why!
The Text=[mVolume:] option has to be used when you want to force the String meter to show the numeric value of the [mVolume] measure. For instance [mVolume] being a Win7Audio plugin measure, as eclectic-tech described, it returns two different values: a numeric (the volume level) and a string (current sound device name) value. If you add a MeasureName=mVolume and a Text=%1 option, the meter will show the name of the current sound device. If you add Text=[mVolume:] option, it will show the volume level.
Additionally, you can even force the meter to show the volume level with defined number of decimals, adding the appropriate number after the colon. For instance the Text=[mVolume:2] option will show the value with two decimals.
If on the other hand the measure set through the MeasureName option returns a numerical value a similar behavior can be achieved adding a NumOfdecimals=2 option to the String meter (note that in this case the meter has to have a MeasureName=... and a Text=%1 option set). This way can you get the String meter to show the value returned by a Calc measure for example with defined number of decimals.
User avatar
balala
Rainmeter Sage
Posts: 11172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help in programming

Post by balala »

sl23 wrote:
November 9th, 2019, 8:08 pm
How do I know which Measure to use? Now that you've changed it.
The correct measure is appropriately set, not this is the issue. You've forgot to add a DynamicVariables=1 option to the [msVolume] measure. This is absolutely required, since the measure uses section variables ([mVolume:] is a such section variable) and these are requireing setting the dynamic variables.
User avatar
sl23
Posts: 411
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Help in programming

Post by sl23 »

Thanks for the explanation balala.
I added DynamicVariables=1 and still it doesn't work corrrectly. There is a long delay between changing volume and the meter update.
User avatar
sl23
Posts: 411
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Help in programming

Post by sl23 »

It's ok, I used eclectic-tech's code and used a !SetOption bang to change it to Muted. Thanks to you both for the help
User avatar
balala
Rainmeter Sage
Posts: 11172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help in programming

Post by balala »

sl23 wrote:
November 9th, 2019, 8:56 pm
Thanks for the explanation balala.
I added DynamicVariables=1 and still it doesn't work corrrectly. There is a long delay between changing volume and the meter update.
Could you please post the current code?

Note two more details, related to this code:
  • Update=25? Why? No need to set the Update so low. Note that as less are you setting it, as more resources requires the skin. For skins showing the volume level, the default Update=1000 is usually completly enough.
  • The [!SetOption mVolume Formula "($MouseX:%$)"] bang used into the LeftMouseUpAction option of the [VolBar] meter is completely wrong. [mVolume] is not a Calc measure, so you can't set a Formula to it. Later in the same LeftMouseUpAction option you have a [!CommandMeasure "mVolume" "SetVolume [mVolume]"] option, which is wrong as well. I suppose the first bang (which sets the Formula) has remaind there from a previously existing and later modified option, so you should remove it. The !CommandMeasure bang is wrong because you can't set the volume level of the [mVolume] measure, setting it to the value of [mVolume] itself. I'd replace this !CommandMeasure bang with the following one: [!CommandMeasure "mVolume" "SetVolume $MouseX:%$"]. This way when you click to the bar, the volume level is set to the appropriate value of the place where you clicked.
User avatar
sl23
Posts: 411
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Help in programming

Post by sl23 »

Update=25 - This is due to using an audio meter in the skin.
I also have UpdateDivider=1000 which is used for the Volume parts of the skin.

I reverted the code back to the original as It was causing other problems.
It's not a problem not having Mute status shown correctly tbh, as I rarely Mute the system anyway.

Here's the code again with the removed section detailed in the post below:

Code: Select all

[Rainmeter]
Update=25
BackgroundMode=2
SolidColor=0,0,0,1
SkinHeight=39
DynamicWindowSize=1
AccurateText=1
LeftMouseUpAction=[!ToggleMeter sTime][!ToggleMeter Time][!Redraw]
MouseOverAction=[!ShowMeterGroup Hover] [!UpdateMeterGroup *] [!SetOption VolLevel FontColor "128,255,0"] [!UpdateMeter *] [!Redraw]
MouseLeaveAction=[!HideMeterGroup Hover] [!UpdateMeterGroup *] [!SetOption VolLevel FontColor "175,175,175"] [!UpdateMeter *] [!Redraw]
MouseScrollUpAction=[!CommandMeasure "mVolume" "ChangeVolume 5"] [!UpdateMeasure mVolume] [!UpdateMeter VolBar] [!UpdateMeasure mVolume] [!UpdateMeter *] [!Redraw]
MouseScrollDownAction=[!CommandMeasure "mVolume" "ChangeVolume -5"] [!UpdateMeasure mVolume] [!UpdateMeter VolBar] [!UpdateMeasure mVolume] [!UpdateMeter *] [!Redraw]
MiddleMouseUpAction=[!CommandMeasure "mVolume" "ToggleMute"] [!UpdateMeasure mVolume] [!UpdateMeter VolBar] [!UpdateMeasure mVolume] [!UpdateMeter *] [!Redraw]

[Metadata]
Author=sl23
Description=Volume Button
Version=1.0

[Variables]
VolLow=25
VolMax=80
UD1=1000

APP1Name=Waterfox
APP2Name=Thunderbird
APP3Name=MuLab
APP4Name=D: SyMenu
APP5Name=E: SyMenu
APP6Name=TEST

APP1=#PROGRAMDRIVE#\SyMenu\SyMenu.exe -run1d09991b-c35b-4a1a-bb03-4aa3fe583e47
APP2=["#PROGRAMPATH#..\..\MyApps\PA.c\PortableApps\ThunderbirdPortable\ThunderbirdPortable.exe"]
APP3=#PROGRAMDRIVE#\SyMenu\SyMenu.exe -runc6a1b119-a0ab-47b2-85ed-436f8573c9b4
APP4=["#PROGRAMPATH#..\..\..\..\SyMenu.exe"]
APP5=E:\SyMenu\SyMenu.exe
App6=

========================================
; VLC
========================================
[mProcessVLC]
Measure=Plugin
Plugin=Process
ProcessName=VLC.exe
;IfCondition=mProcessVLC=1
;IfTrueAction=[!HideMeterGroup VLC] [!UpdateMeterGroup *] [!Redraw]
;IfFalseAction=[!ShowMeterGroup VLC] [!UpdateMeterGroup *] [!Redraw]

========================================
; STYLES
========================================

[sHiLite]
Shape=Rectangle 0,0,90,16,5 | Fill Color 30,30,30 | StrokeWidth 2 | StrokeColor 255,128,0
Hidden=1
UpdateDivider=#UD1#
X=-15r
Y=1

[sName]
FontFace=Corbel
StringStyle=Bold
StringAlign=Center
FontSize=10
FontColor=0,255,255
AntiAlias=1
Hidden=1
UpdateDivider=#UD1#
X=45r
Y=-1r

[sStroke]
MouseOverAction=[!SetOption #CURRENTSECTION# StrokeAlpha "Stroke Color 128,255,0,255"][!ShowMeter #CURRENTSECTION#Name][!ShowMeter #CURRENTSECTION#HiLite][!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# StrokeAlpha ""][!HideMeter #CURRENTSECTION#Name][!HideMeter #CURRENTSECTION#HiLite][!UpdateMeter *][!Redraw]
Shape=Rectangle 0,0,16,16,50 | Fill Color 60,60,60 | StrokeWidth 3 | Extend StrokeAlpha
StrokeAlpha=Stroke Color 128,255,0,0
DynamicVariables=1
Group=VLC
UpdateDivider=#UD1#
X=-6r
Y=18r

========================================
; APP 1
========================================
[BG1HiLite]
Meter=Shape
MeterStyle=sHiLite
X=1R

[BG1Name]
Meter=String
MeterStyle=sName
Text=#APP1Name#

[BG1]
Meter=Shape
MeterStyle=sStroke
LeftMouseUpAction=#APP1#
Y=18

========================================
; APP 2
========================================
[BG2HiLite]
Meter=Shape
MeterStyle=sHiLite

[BG2Name]
Meter=String
MeterStyle=sName
Text=#APP2Name#

[BG2]
Meter=Shape
MeterStyle=sStroke
LeftMouseUpAction=#APP2#

========================================
; APP 3
========================================
[BG3HiLite]
Meter=Shape
MeterStyle=sHiLite

[BG3Name]
Meter=String
MeterStyle=sName
Text=#APP3Name#

[BG3]
Meter=Shape
MeterStyle=sStroke
LeftMouseUpAction=#APP3#

========================================
; APP 4
========================================
[BG4HiLite]
Meter=Shape
MeterStyle=sHiLite

[BG4Name]
Meter=String
MeterStyle=sName
Text=#APP4Name#

[BG4]
Meter=Shape
MeterStyle=sStroke
LeftMouseUpAction=#APP4#

========================================
; APP 5
========================================
[BG5HiLite]
Meter=Shape
MeterStyle=sHiLite

[BG5Name]
Meter=String
MeterStyle=sName
Text=#APP5Name#

[BG5]
Meter=Shape
MeterStyle=sStroke
LeftMouseUpAction=#APP5#

========================================
; APP 6
========================================
[BG6HiLite]
Meter=Shape
MeterStyle=sHiLite

[BG6Name]
Meter=String
MeterStyle=sName
Text=#APP6Name#

[BG6]
Meter=Shape
MeterStyle=sStroke
LeftMouseUpAction=#APP6#

========================================
; VU METRE
========================================
[mPlayer]
Measure=Plugin
Plugin=NowPlaying
PlayerType=STATUS
PlayerName=CAD
IfCondition=(mPlayer=1)
IfTrueAction=[!ShowMeterGroup Player] [!UpdateMeter *] [!Redraw]
IfFalseAction=[!HideMeterGroup Player] [!UpdateMeter *] [!Redraw]

[mAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=50
RMSDecay=300
RMSGain=2.0
PeakAttack=100
PeakDecay=3000
PeakGain=2.0

[mLeft]
Measure=Plugin
Plugin=AudioLevel
Parent=mAudio
Type=RMS
Channel=L

[Left]
Meter=Bar
MeasureName=mLeft
BarImage=OcenVUMetre - Mini 180x4
BarOrientation=Horizontal
Group=Player
Y=36

========================================
; VOLUME
========================================
[mVolume]
Measure=Plugin
Plugin=Win7AudioPlugin
UpdateDivider=#UD1#
DynamicVariables=1

[VolLevel]
Meter=String
Text=[mVolume:]
FontFace=Corbel
StringStyle=Bold
FontSize=12
FontColor=175,175,175
SolidColor=0,0,0,1
AntiAlias=1
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure "mVolume" "SetVolume #VolLow#"] [!UpdateMeasure mVolume] [!UpdateMeter *] [!Redraw]
RightMouseUpAction=[!CommandMeasure "mVolume" "SetVolume #VolMax#"] [!UpdateMeasure mVolume] [!UpdateMeter *] [!Redraw]
MiddleMouseUpAction=ms-settings:sound
Substitute="-1":"MUTED"
X=2
Y=15

[VolBar]
Meter=Bar
MeasureName=mVolume
BarColor=255,128,0
SolidColor=60,60,60
BarOrientation=Horizontal
DynamicVariables=1
Hidden=1
Group=Hover
Y=36
W=180
H=2
Last edited by sl23 on November 10th, 2019, 12:18 am, edited 2 times in total.
User avatar
sl23
Posts: 411
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Help in programming

Post by sl23 »

The [!SetOption mVolume Formula "($MouseX:%$)"] bang used into the LeftMouseUpAction option of the [VolBar] meter is completely wrong. [mVolume] is not a Calc measure, so you can't set a Formula to it. Later in the same LeftMouseUpAction option you have a [!CommandMeasure "mVolume" "SetVolume [mVolume]"] option, which is wrong as well. I suppose the first bang (which sets the Formula) has remaind there from a previously existing and later modified option, so you should remove it. The !CommandMeasure bang is wrong because you can't set the volume level of the [mVolume] measure, setting it to the value of [mVolume] itself. I'd replace this !CommandMeasure bang with the following one: [!CommandMeasure "mVolume" "SetVolume $MouseX:%$"]. This way when you click to the bar, the volume level is set to the appropriate value of the place where you clicked.
I've removed it as it's no longer required for this skin. Thanks for pointing it out.
User avatar
balala
Rainmeter Sage
Posts: 11172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help in programming

Post by balala »

sl23 wrote:
November 9th, 2019, 8:56 pm
There is a long delay between changing volume and the meter update.
sl23 wrote:
November 10th, 2019, 12:02 am
Update=25 - This is due to using an audio meter in the skin.
I also have UpdateDivider=1000 which is used for the Volume parts of the skin.
Normally. You have the Update value set to Update=25 and on those meters UpdateDivider=1000. This means the meters are updated once per 25 x 1000 milliseconds = 25 seconds. Practically twice per minute.
To get one update per second, set the UD1 variable to UD1=40. This means the meters will be updated once per 25 x 40 miiliseconds = 1000 milliseconds = 1 second. Now it'll be ok.