It is currently May 3rd, 2024, 5:43 pm

I'm trying to do "if ... !execute ... else !execute ..."

Get help with creating, editing & fixing problems with skins
linksku
Posts: 3
Joined: September 6th, 2011, 12:37 am

I'm trying to do "if ... !execute ... else !execute ..."

Post by linksku »

Hi, this is my first post. I'm new to Rainmeter.

I downloaded the "Soita" skin, which is a Windows Media Player skin that can control WMP from the desktop using nowplaying.dll

However, I want to modify it to make the Play button open WMP if WMP isn't already opened. I spent the last hour Googling and experimenting, but nothing worked.

Here's what I have so far:

Code: Select all

[Variables]
PlayPauseVar=""

[mStateButtonCustom]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=[mPlayer]
PlayerType=STATE
Substitute="0":0,"1":1,"2":1
DynamicVariables=1

[PlayPauseOROpen]
Measure=Calc
Formula=[mStateButtonCustom]
IfBelowValue=1
IfBelowAction=!RainmeterSetVariable PlayPauseVar "C:\Program Files\Windows Media Player\wmplayer.exe"
IfEqualValue=1
IfEqualAction=!RainmeterSetVariable PlayPauseVar !RainmeterPluginBang "mPlayer PlayPause"
DynamicVariables=1

[Play]
Meter=BUTTON
ButtonImage=[mStateButton]
X=25r
Y=115 
LeftMouseUpAction=!Execute [#PlayPauseVar#] 
DynamicVariables=1
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: I'm trying to do "if ... !execute ... else !execute ..."

Post by Mordasius »

I think it will work if you replace [mStateButton] and [Play] with the following:

Code: Select all

[mStateButtonCustom]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=[mPlayer]
PlayerType=STATE
IfBelowValue=1
         IfBelowAction=!Execute [!SetOption "PlayPauseOrOpen" "ButtonImage" "Play.png"]   [!SetOption "PlayPauseOrOpen" "LeftMouseUpAction" """!PluginBang "mPlayer OpenPlayer""""]		 	 
IfEqualValue=1
        IfEqualAction=!Execute [!SetOption "PlayPauseOrOpen" "ButtonImage" "Pause.png"] [!SetOption "PlayPauseOrOpen" "LeftMouseUpAction" """!PluginBang "mPlayer PlayPause""""]
IfAboveValue=1
		IfAboveAction=!Execute [!SetOption "PlayPauseOrOpen" "ButtonImage" "Play.png"] [!SetOption "PlayPauseOrOpen" "LeftMouseUpAction" """!PluginBang "mPlayer PlayPause""""]		
	
...

[PlayPauseOrOpen]
Meter=BUTTON
X=25r
Y=115
There again you could always use the "Open Media Player" button on the right of the Soita skin!
linksku
Posts: 3
Joined: September 6th, 2011, 12:37 am

Re: I'm trying to do "if ... !execute ... else !execute ..."

Post by linksku »

I can't believe I never saw the "Open Media Player" button. Thank!

Now I want to play a random song when the media player opens. Since WMP can't be set to open a random song, I thought I can execute 3 commands in one click (OpenPlayer, Play, Next). Since it's possible to sort the songs randomly, "Next" would play a random song.

Here's the closest I got:

Code: Select all

[OpenPlayer]
Meter=BUTTON
ButtonImage=Open.png
X=355
Y=115
ToolTipText="Open Media Player"
LeftMouseDownAction=!Execute [!RainmeterPluginBang "mPlayer OpenPlayer"]
LeftMouseUpAction=!Execute [!RainmeterPluginBang "mPlayer Play"]
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: I'm trying to do "if ... !execute ... else !execute ..."

Post by poiru »

linksku wrote:Now I want to play a random song when the media player opens. Since WMP can't be set to open a random song, I thought I can execute 3 commands in one click (OpenPlayer, Play, Next). Since it's possible to sort the songs randomly, "Next" would play a random song.

Here's the closest I got:

Code: Select all

[OpenPlayer]
Meter=BUTTON
ButtonImage=Open.png
X=355
Y=115
ToolTipText="Open Media Player"
LeftMouseDownAction=!Execute [!RainmeterPluginBang "mPlayer OpenPlayer"]
LeftMouseUpAction=!Execute [!RainmeterPluginBang "mPlayer Play"]
You could also do something like this (note: not tested, should work):

Code: Select all

[mDelayCommand]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=[mPlayer]
PlayerType=STATUS
IfEqualAction=1
IfEqualAction=!Execute [!PluginBang "mPlayer Play"][!PluginBang "mPlayer Next"][!DisableMeasure "mDelayCommand"]

[OpenPlayer]
Meter=BUTTON
ButtonImage=Open.png
X=355
Y=115
ToolTipText="Open Media Player"
LeftMouseUpAction=!Execute [!PluginBang "mPlayer OpenPlayer"][!EnableMeasure "mDelayCommand"]
(Clicking on Open Player activates the mDelayCommand measure, which executes the Play and Next commands when WMP is active)
linksku
Posts: 3
Joined: September 6th, 2011, 12:37 am

Re: I'm trying to do "if ... !execute ... else !execute ..."

Post by linksku »

Rainmeter returned several errors, so I modified it into the following, and it's still not working:

Code: Select all

[mDelayCommand]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=[mPlayer]
PlayerType=STATUS
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterPluginBang "mPlayer Play"][!RainmeterPluginBang "mPlayer Next"][!RainmeterDisableMeasure "mDelayCommand"]

[OpenPlayer]
Meter=BUTTON
ButtonImage=Open.png
X=355
Y=115
ToolTipText="Open Media Player"
LeftMouseUpAction=!Execute [!RainmeterPluginBang "mPlayer OpenPlayer"][!RainmeterEnableMeasure "mDelayCommand"]
Is there no simple way to delay execution in RainMeter?