It is currently December 12th, 2019, 8:20 pm

Variable commands?

Help with creating, editing & fixing problems with skins
ItsJustRyan
Posts: 37
Joined: October 25th, 2019, 1:20 am

Variable commands?

ItsJustRyan » November 26th, 2019, 2:02 am

Hi!
Right now I'm using one of the fully supported music players, and I've set up a kind of button to show me whether it is on or off. In the past I had it so that when i clicked on the text it turned off and it turned on when i pressed the circle. I'm currently trying to make it so that it toggles, as for some reason when I used the toggleplayer thing it only works when turning off. Any ideas?

Code: Select all

[Rainmeter]
 Update=16
 Author=Ryan

[Variables]

[OnOff]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=AIMP
PlayerType=Status
IfCondition=(OnOff = 0)
IfTrueAction=[!SetOption "Text.Volume" "Text" "AIMP Off"]
IfFalseAction=[!SetOption "Text.Volume" "Text" "AIMP On"]

[OnOff2]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=AIMP
PlayerType=Status
IfCondition=(OnOff = 1)
IfTrueAction=[!SetVariable OnCol "22bb45"]
IfFalseAction=[!SetVariable OnCol "255,0,0,255"]

[OnOff3]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=AIMP
PlayerType=Status
IfCondition=(OnOff = 1)
IfTrueAction=[!SetVariable com ClosePlayer]
IfFalseAction=[!SetVariable com OpenPlayer]
 
[Text.Volume]
 Meter=String
 MeasureName=OnOff
 X=0
 Y=0
 Text=%1
 FontFace=Lato 
 FontSize=15
 FontColor=FF8800
 FontWeight=500
 StringAlign=Left
 AntiAlias=1
 ClipString=1
 W=175

[MeterEllipse]
Meter=Shape
MeasureName=com
Shape=Ellipse 100,14,8 | Stroke Color 0,0,0,1 | Fill Color #OnCol#
DynamicVariables=1
LeftMouseUpAction=["#com#"]
[Code]
mak_kawa
Posts: 371
Joined: December 30th, 2015, 9:47 am

Re: Variable commands?

mak_kawa » November 26th, 2019, 2:25 am

I think the player command you used is incorrect. Use LeftMouseUpAction=[!CommandMeasure OnOff "#com#"] instead of [LeftMouseUpAction="#com#"].

Following code does work well for me.

Code: Select all

[Rainmeter]
Update=1000

[Variables]

[OnOff]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=AIMP
PlayerPath=C:\Program Files (x86)\AIMP\AIMP.exe
PlayerType=Status
IfCondition=(OnOff = 0)
IfTrueAction=[!SetOption "Text.Volume" "Text" "AIMP Off"]
IfFalseAction=[!SetOption "Text.Volume" "Text" "AIMP On"]

[OnOff2]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=AIMP
PlayerType=Status
IfCondition=(OnOff = 1)
IfTrueAction=[!SetVariable OnCol "22bb45"]
IfFalseAction=[!SetVariable OnCol "255,0,0,255"]

[OnOff3]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=AIMP
PlayerType=Status
IfCondition=(OnOff = 1)
IfTrueAction=[!SetVariable com ClosePlayer]
IfFalseAction=[!SetVariable com OpenPlayer]
 
[Text.Volume]
Meter=String
MeasureName=OnOff
X=0
Y=0
Text=%1
FontFace=Lato 
FontSize=15
FontColor=FF8800
FontWeight=500
StringAlign=Left
AntiAlias=1
ClipString=1
W=175

[MeterEllipse]
Meter=Shape
MeasureName=com
Shape=Ellipse 100,14,8 | Stroke Color 0,0,0,1 | Fill Color #OnCol#
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure OnOff "#com#"]
PlayerPath is necessary for my PC. I am not sure whether it is necessary also for you or not.
User avatar
balala
Rainmeter Sage
Posts: 9258
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Variable commands?

balala » November 26th, 2019, 11:47 am

Beside mak_kawa's reply, also note that there is not needed to use three times the same NowPlaying (plugin) measure, with the same PlayerType=Status option, one is completely enough. You can add all those bangs used into the three IfTrueAction / IfFalseAction options into one single:

Code: Select all

[OnOff]
Measure=NowPlaying
PlayerName=AIMP
PlayerPath=C:\Program Files (x86)\AIMP\AIMP.exe
PlayerType=Status
IfCondition=(OnOff = 0)
IfTrueAction=[!SetOption Text.Volume Text "AIMP Off"][!SetVariable OnCol "255,0,0,255"][!SetVariable com "OpenPlayer"]
IfFalseAction=[!SetOption Text.Volume Text "AIMP On"][!SetVariable OnCol "22bb45"][!SetVariable com "ClosePlayer"]
Much more concise, so more convenient.
I also rewrote the measure not to be a plugin measure, but a NowPlaying measure, because although a while ago NowPlaying was a plugin, in meantime it became a measure and on newer codes you should use it so.
ItsJustRyan
Posts: 37
Joined: October 25th, 2019, 1:20 am

Re: Variable commands?

ItsJustRyan » November 27th, 2019, 4:12 am

Thanks both of you :) This worked
User avatar
balala
Rainmeter Sage
Posts: 9258
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Variable commands?

balala » November 27th, 2019, 7:02 pm

ItsJustRyan wrote:
November 27th, 2019, 4:12 am
Thanks both of you :) This worked
I'm glad, however you shouldn't thank me, mak_kawa has fixed your issue, I just adviced you how to reduce the length of the code and the number of measures.