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

Help with $MouseX$

Get help with creating, editing & fixing problems with skins
dimentio64
Posts: 13
Joined: August 24th, 2015, 4:49 pm

Help with $MouseX$

Post by dimentio64 »

I currently am refining my code and I'm having difficulty with implementing a volume bar. I want clicking on the volume bar to change the volume so I have the code

LeftMouseDownAction=!CommandMeasure "Measure_Player" "SetVolume (($MouseX$-#xoffset#)/(#VolumeWidth#)*100)"

This always sets the volume to 0, but substituting the (($MouseX$-#xoffset#)/(#VolumeWidth#)*100) for a simple integer works just fine. I assume I must just be making a mistake in my code somwhere? If anyone could advise it would be greatly appreciated.
dimentio64
Posts: 13
Joined: August 24th, 2015, 4:49 pm

Re: Help with $MouseX$

Post by dimentio64 »

Ok, apparently it actually is just that it doesn't like the calculations happening inside of the bang. Does anyone know how to implement formulae into bangs?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with $MouseX$

Post by jsmorley »

I'm no expert on NowPlaying, and never really use it, but I think you are right. It doesn't seem to like formulas in the SetVolume command. You can get around that with:

Code: Select all

[VolumeFormula]
Measure=Calc

[VolumeSelect]
Meter=Image
W=300
H=20
SolidColor=47,47,47,255
LeftMouseDownAction=[!SetOption VolumeFormula Formula "(($MouseX$-#xoffset#)/(#VolumeWidth#)*100)"][!UpdateMeasure VolumeFormula][!CommandMeasure "Measure_Player" "SetVolume [VolumeFormula]"]
dimentio64
Posts: 13
Joined: August 24th, 2015, 4:49 pm

Re: Help with $MouseX$

Post by dimentio64 »

I tried this and it still ended up resulting in the volume setting to 0. Curious, and with the implementation of this new measure, I tried printing the value to the screen. Apparently the measure only ever displays 0, desoite me clicking various area trying to update the value... Did I possibly typo the code?

---

[VolumeFormula]
Measure=Calc

[Bar_MasterVolume]
Meter=BAR
MeasureName=Measure_Win7Audio
BarOrientation=HORIZONTAL
AntiAlias=1
MaxValue=100
MinValue=0
AutoScale=0
X=1r
Y=1r
H=6
W=(#VolumeWidth#-2)
BarColor=#secondaryColor#
LeftMouseDownAction=[!SetOption VolumeFormula Formula "(($MouseX$-(#xArtistLabelOffset#+2+10))/(#VolumeWidth#-2)*100)"][!UpdateMeasure VolumeFormula][!CommandMeasure "Measure_Player" "SetVolume [VolumeFormula]"]

[test]
Meter=string
MeasureName=VolumeFormula
X=1r
Y=1r
text=%1
dimentio64
Posts: 13
Joined: August 24th, 2015, 4:49 pm

Re: Help with $MouseX$

Post by dimentio64 »

Also tried

=[!SetOption VolumeFormula Formula "75"][!UpdateMeasure VolumeFormula][!CommandMeasure "Measure_Player" "SetVolume [VolumeFormula]"]
=[!SetOption VolumeFormula "75"][!UpdateMeasure VolumeFormula][!CommandMeasure "Measure_Player" "SetVolume [VolumeFormula]"]

Both have the same result. I feel the measure isn't properly being updated perhaps??
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with $MouseX$

Post by jsmorley »

dimentio64 wrote:Also tried

=[!SetOption VolumeFormula Formula "75"][!UpdateMeasure VolumeFormula][!CommandMeasure "Measure_Player" "SetVolume [VolumeFormula]"]
=[!SetOption VolumeFormula "75"][!UpdateMeasure VolumeFormula][!CommandMeasure "Measure_Player" "SetVolume [VolumeFormula]"]

Both have the same result. I feel the measure isn't properly being updated perhaps??
You might try:

[VolumeFormula]
Measure=Calc
DynamicVaribles=1

I can't see how or where those #Variables# in the formula are being set, but if they are not static, and are somehow driven by some measure value or other dynamic value, then the Calc measure will need to have DynamicVariables=1 on it.
dimentio64
Posts: 13
Joined: August 24th, 2015, 4:49 pm

Re: Help with $MouseX$

Post by dimentio64 »

The variables are just for setting the position of the bar, and are static vars defined at the top.

DynamicVariables didn't Work :(

Is it possibly one of the [!SetOption VolumeFormula Formula "75"][!UpdateMeasure VolumeFormula] ? Neither seem to set the value of the formula to 75...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Help with $MouseX$

Post by eclectic-tech »

This may not help, but have you tried using section variables measure parameters in
LeftMouseDownAction=...[!CommandMeasure "Measure_Player" "SetVolume [VolumeFormula:]"] bang,
to ensure you use the numerical value...

Code: Select all

[VolumeFormula]
Measure=Calc

[Bar_MasterVolume]
Meter=BAR
MeasureName=Measure_Win7Audio
BarOrientation=HORIZONTAL
AntiAlias=1
MaxValue=100
MinValue=0
AutoScale=0
X=1r
Y=1r
H=6
W=(#VolumeWidth#-2)
BarColor=#secondaryColor#
LeftMouseDownAction=[!SetOption VolumeFormula Formula "(($MouseX$-(#xArtistLabelOffset#+2+10))/(#VolumeWidth#-2)*100)"][!UpdateMeasure VolumeFormula][!CommandMeasure "Measure_Player" "SetVolume [VolumeFormula:]"]
DynamicVariables=1

[test]
Meter=string
MeasureName=VolumeFormula
X=1r
Y=1r
text=%1
You have to add DynamicVariables=1 when using section variables.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with $MouseX$

Post by jsmorley »

I'm just not sure. I pretty much created the exact situtation:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
VolumeWidth=300
xoffset=0

[Measure_Player]
Measure=Plugin
Plugin=NowPlaying
PlayerName=WinAMP
PlayerType=TITLE

[VolumeFormula]
Measure=Calc

[VolumeSelect]
Meter=Image
W=300
H=20
SolidColor=47,47,47,255
LeftMouseDownAction=[!SetOption VolumeFormula Formula "(($MouseX$-#xoffset#)/(#VolumeWidth#)*100)"][!UpdateMeasure VolumeFormula][!CommandMeasure "Measure_Player" "SetVolume [VolumeFormula]"]
And it works just fine for me.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Help with $MouseX$

Post by eclectic-tech »

That's weird... I didn't try the code, but if it works on your system, there has to be something else going on.

Maybe posting the entire skin code can help find the issue?
It might help to know what Rainmeter version and the operating system the OP is using too...