It is currently March 29th, 2024, 2:41 pm

Selective OnChangeAction depending on value

Get help with creating, editing & fixing problems with skins
User avatar
Pflosch
Posts: 39
Joined: May 24th, 2020, 7:04 am
Location: Switzerland

Selective OnChangeAction depending on value

Post by Pflosch »

Hi, I'm new here.

Trying to make a skin which will close the music player if not in use for 10min.

I have an ActionTimer measure which kills the player (PSkill) after 10min.

I am trying to trigger/reset it, with OnChangeAction of NowPlaying/state.
How do I evaluate the state (0,1,2) and set different actions to excecute depending on it's value? ("execute ActionTimer" or "Stop ActionTimer").
Also I do not know whether the "substitute" part was already done or not...
In the snippet, what's indented is what doesn't work. I tried 1001 different syntaxes, none of them worked.

Hope that was understandable, help would be appreciated.

Code: Select all

[mState]
Measure=NowPlaying
PlayerName=Winamp
PlayerType=STATE
Substitute="0":"Play.png","1":"Pause.png","2":"Play.png"

	KiActPlay.png=[!CommandMeasure mKillTimer "Execute 1"]
	KiActPause.png=[!CommandMeasure mKillTimer "Stop 1"]
	KiAct0=[!CommandMeasure mKillTimer "Execute 1"]
	KiAct0=[!CommandMeasure mKillTimer "Stop 1"]
	OnChangeAction=[!KiAct#STATE#]

[mKillTimer]
Measure=Plugin
Plugin=ActionTimer
ActionList1= wait 1000 | ["#@#PSkill\KillWinamp.bat"]
I think maybe no problem.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Selective OnChangeAction depending on value

Post by balala »

Pflosch wrote: May 24th, 2020, 7:47 am Hope that was understandable, help would be appreciated.
Besides dvo's reply, here is a suggestion, at least what have I understood.
First not sure what the KiActPlay.png, KiActPause.png and KiAct0 (posted twice with different values) are. The first two (KiActPlay.png and KiActPause.png) should be some images (based on the .png extension), but why are the posted so? Or should they be placed under the [Variables] section? Not sure.
However what I understood is that you'd like to is to execute the ActionList of the ActionTimer plugin measure ([mKillTimer]) when the player is playing or when it is paused / stopped (not sure which one from these two). These can be achieved through !CommandMeasure bangs, added to a set of IfTrueAction / IfFalseAction options of an IfCondition. Something like this:

Code: Select all

[mState]
Measure=NowPlaying
PlayerName=Winamp
PlayerType=STATE
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!CommandMeasure "mKillTimer" "Execute 1"]
IfFalseAction=[!CommandMeasure "mKillTimer" "Stop 1"]
No need for substitution, at least so far.
What the above IfCondition (and the subsequent IfTrueAction and IfFalseAction options) does/do? The IfCondition is evaluated. If the value returned by the #CURRENTSECTION# (so by the [mState] measure) is equal to 1, the bang of the IfTrueAction option is executed, so the ActionList1 of the [mKillTimer] measure is executed. Otherwise, if the condition is false, obviously the bang of IfFalseAction is executed, stopping the ActionList1 of the [mKillTimer] measure.
User avatar
Pflosch
Posts: 39
Joined: May 24th, 2020, 7:04 am
Location: Switzerland

Re: Selective OnChangeAction depending on value

Post by Pflosch »

Wow... now that's called fast response. :D
Thanks heaps to both of you.

dvo,
your code does not really sort out my issue. It sets visibility of skins based on "state" and "status" of NowPlaying.

balala,
yes, that's pretty much what I'm after, only like this it doesn't work :-(
I think it's because the timer gets restarted on each cycle and the 2nd item of ActionList1 never gets executed.
That's why I wanted to use OnChangeAction in first place. Is there a way to evaluate "state" when OnChangeAction" triggers as well?

edit...sorry....not native english speaker.. :/
I think maybe no problem.
User avatar
Pflosch
Posts: 39
Joined: May 24th, 2020, 7:04 am
Location: Switzerland

Re: Selective OnChangeAction depending on value

Post by Pflosch »

Regarding the .png stuff... never mind, that has nothing to do with it, i delete it for simplicity...
I had two values, becoz I didn't know whether "substitute" was already executed or not...
So now with your suggested code it now looks like this:

Code: Select all

[mState]
Measure=NowPlaying
PlayerName=Winamp
PlayerType=STATE
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!CommandMeasure "mKillTimer" "Execute 1"]
IfFalseAction=[!CommandMeasure "mKillTimer" "Stop 1"]

[mKillTimer]
Measure=Plugin
Plugin=ActionTimer
ActionList1= wait 1000 | ["#@#PSkill\KillWinamp.bat"]
I think maybe no problem.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Selective OnChangeAction depending on value

Post by balala »

Pflosch wrote: May 24th, 2020, 8:48 am balala,
yes, that's pretty much what I'm after, only like this it doesn't work :-(
I think it's because the timer gets restarted on each cycle and the 2nd item of ActionList1 never gets executed.
That's why I wanted to use OnChangeAction in first place. Is there a way to evaluate "state" when OnChangeAction" triggers as well?
But are you sure the [mKillTimer] ActionTimer plugin measure is needed? I mean that maybe you could get rid of it:

Code: Select all

[mState]
Measure=NowPlaying
PlayerName=Winamp
PlayerType=STATE
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!Delay "1000"]["#@#PSkill\KillWinamp.bat"]
With the above code, when the player is playing, the [mState] gets 1 and the IfTrueAction is executed. It waits one second (due to the first !Delay bang), then the Winamp.bat file is ran. If the player is stopped or paused, the IfCondition becomes false and accordingly nothing is executed.
As you can see and as I said, I think the ActionTimer plugin measure is not needed.
User avatar
Pflosch
Posts: 39
Joined: May 24th, 2020, 7:04 am
Location: Switzerland

Re: Selective OnChangeAction depending on value

Post by Pflosch »

Yep, I would love to make it simpler...
And yes it works "halfway".

If I start the player, then stop it, it will be killed after the specified time. so far OK.
but:
If I start the player, then stop it (e.g.song finished) then start it again, it still will be killed after the specified time from when it stopped.

So... to make that working, I would need to IfNotTrueAction= "reset that action started before"

Also... I do not understand "why"... I would expect "state" to be evaluated each cycle and the delay to restart each cycle... but it doesn't...
I think maybe no problem.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Selective OnChangeAction depending on value

Post by balala »

Pflosch wrote: May 24th, 2020, 9:36 am I would need to IfNotTrueAction= "reset that action started before"
There is no an IfNotTrueAction option, just an IfFalseAction.
Pflosch wrote: May 24th, 2020, 9:36 am If I start the player, then stop it, it will be killed after the specified time. so far OK.
but:
If I start the player, then stop it (e.g.song finished) then start it again, it still will be killed after the specified time from when it stopped.
Alright, please pack the whole config, which contains the .ini file which includes the previously posted [mState] and [mKillTimer] measures and upload the package here. I'd like to check what's going on there and would need the KillWinamp.bat file as well.
User avatar
Pflosch
Posts: 39
Joined: May 24th, 2020, 7:04 am
Location: Switzerland

Re: Selective OnChangeAction depending on value

Post by Pflosch »

Oh.. I got it working.
Your help brought me to the right direction.
Thank you very much :)

Code: Select all

[mState]
Measure=NowPlaying
PlayerName=Winamp
PlayerType=STATE
IfCondition=(#CURRENTSECTION#=0)||(#CURRENTSECTION#=2)
IfTrueAction=[!CommandMeasure "mKillTimer" "Execute 1"]
IfFalseAction=[!CommandMeasure "mKillTimer" "Stop 1"]
Substitute="0":"Play.png","1":"Pause.png","2":"Play.png"

[mKillTimer]
Measure=Plugin
Plugin=ActionTimer
ActionList1= wait 600000|KillIt
KillIt=["#@#PSkill\KillWinamp.bat"]
I think maybe no problem.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Selective OnChangeAction depending on value

Post by balala »

Pflosch wrote: May 24th, 2020, 12:11 pm Oh.. I got it working.
Your help brought me to the right direction.
Alright, I'm glad.
There is only one small detail I'd add: although there is nothing wrong with your IfCondition, I'd simplify it a little be, for instance replacing the following options of the [mState] measure. Leave untouched the other ones:

Code: Select all

[mState]
...
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!CommandMeasure "mKillTimer" "Stop 1"]
IfFalseAction=[!CommandMeasure "mKillTimer" "Execute 1"]
...
As said, your IfCondition has nothing wrong, it does work. This one is just a little bit simpler, the code is easier to be followed later if, after a while, you'll have to modify it.
User avatar
Pflosch
Posts: 39
Joined: May 24th, 2020, 7:04 am
Location: Switzerland

Re: Selective OnChangeAction depending on value

Post by Pflosch »

Ah, yes, of course, that's nicer.
Again, thanks very much for your help.
I think maybe no problem.