It is currently March 28th, 2024, 1:26 pm

Variable commands?

Get help with creating, editing & fixing problems with skins
Post Reply
ItsJustRyan
Posts: 81
Joined: October 25th, 2019, 1:20 am

Variable commands?

Post by ItsJustRyan »

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: 908
Joined: December 30th, 2015, 9:47 am

Re: Variable commands?

Post by mak_kawa »

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: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Variable commands?

Post by balala »

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: 81
Joined: October 25th, 2019, 1:20 am

Re: Variable commands?

Post by ItsJustRyan »

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

Re: Variable commands?

Post by balala »

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.
Post Reply