It is currently May 1st, 2024, 11:23 pm

If's and sorting image sources

Get help with creating, editing & fixing problems with skins
p-k-y
Posts: 6
Joined: July 18th, 2012, 1:37 pm

If's and sorting image sources

Post by p-k-y »

So basically in an itunes plugin, when you toggle the power button the button image is changed.
The variable is powericon and it will be set equal to the name of the correct image, my problem is telling if it is already turned on or off, so using an if.

Would i need to have a variable that is either 1 or 0 and if its 1 the player is turned off so show the grey button and minus 1 from the variable then to turn it off switch the button and add 1 ?

very new to this but have done plenty of coding before.
All help appreciated
Thanks

Code: Select all

[PowerActive]
Meter=IMAGE
X=450
Y=335
W=20
H=20
ImageName=#powericon#
if MeasurePower=On then
LeftMouseUpAction=!execute [!RainmeterPluginBang "MeasurePower"][!setVariable #powericon# powerg.png][!RainmeterRedraw]
else
LeftMouseUpAction=!execute [!RainmeterPluginBang "MeasurePower"][!setVariable #powericon# powerb.png][!RainmeterRedraw]
User avatar
UnforgivenRevival
Posts: 310
Joined: June 7th, 2012, 2:25 am
Location: Philadelphia, PA

Re: If's and sorting image sources

Post by UnforgivenRevival »

You need to use an ifaction equation, something like this:

Code: Select all


Ifequalvalue=1
ifequalaction=[!PluginBang MeasurePower][!setVariable powericon powerg.png][!Redraw]
IfBelowValue=1
IfBelowAction=[!PluginBang MeasurePower][!setVariable powericon powerb.png][!Redraw]

Rainmeter doesnt use that type of code you were using. If you were to use something like that, You may want to look into .lua scripting, but might not be needed in this case.

I'm not sure where the measure power bang is coming from, or what its for. May you please post your code here so we can get a better look?
Last edited by UnforgivenRevival on July 18th, 2012, 2:07 pm, edited 1 time in total.
User avatar
gmvolk
Posts: 56
Joined: September 26th, 2011, 11:02 pm

Re: If's and sorting image sources

Post by gmvolk »

Ifs do not work that way, would be nice if they do.
Check http://rainmeter.net/cms/Measures-IfActions
for more information.
"Pub." Ah, yes: a meeting place where people attempt to achieve advanced states of mental incompetence by the repeated consumption of fermented vegetable drinks.

http://gmvolk.deviantart.com/
p-k-y
Posts: 6
Joined: July 18th, 2012, 1:37 pm

Re: If's and sorting image sources

Post by p-k-y »

Ok here is all my code, not sure which value its checking but here it is

Code: Select all

This Circle looks good around the center clock
;Metadata added by RainBrowser
;http://rainmeter.net/RainWiki/index.php?title=Rainmeter_101#.5BMetadata.5D

[Metadata]
Name=
Config=
Description=
Instructions=
Version=
Tags=
License=
Variant=
Preview=

;End of added Metadata
-------------------------------------------------
[Variables]
FontName=UbuntuTitlingRg
Normal Color= 255,255,255,110
powericon=powerb.png
onoroff=1
-------------------------------------------------
[Meters]

[MeasureAlbumArt]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetCurrentTrackArtwork

[MeasureCurrentTrackArtist]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetCurrentTrackArtist

[MeasureCurrentTrackName]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetCurrentTrackName

[MeasureCurrentTrackAlbum]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetCurrentTrackAlbum

[MeasurePlayerPosition]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetPlayerPosition
MaxValue=100


[MeasurePlayerPositionPercent]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetPlayerPositionPercent
MaxValue=100

[mCurrMin]
Measure=Calc
Formula=(MeasurePlayerPosition - (MeasurePlayerPosition % 60)) /60

[mCurrSec]
Measure=Calc
Formula=MeasurePlayerPosition % 60

[mCurrZero]
Measure=Calc
Formula=(MeasurePlayerPosition % 60) < 10 ? 0 : 1
Substitute="1":""

[MeasureCircle]
Measure=Calc
Formula=10

---------------------------------------------------
--iTunes--
[AlbumArt2]
Meter=IMAGE
ImageName=none.png
X=220
Y=240
W=160
H=160

[AlbumArt]
Meter=IMAGE
MeasureName=MeasureAlbumArt
X=220
Y=240
W=160
H=160

[MeterCircle]
Meter=ROUNDLINE
MeasureName=MeasureCircle
X=0
Y=0
W=600
H=600
LineLength=150
LineStart=135
StartAngle=6.5
RotationAngle=6.28318531
AntiAlias=1
LineColor=255, 255,255, 50
Solid=1

[iTunesSongPosition]
MeasureName=MeasurePlayerPositionPercent
Meter=ROUNDLINE
X=0
Y=0
W=600
H=600
LineLength=150
LineStart=135
StartAngle=11
RotationAngle=6.28318531
AntiAlias=1
LineColor=100, 149,237, 50
Solid=1

[iTunesCurrentTrackTime]
Meter=STRING
MeasureName=mCurrMin
MeasureName2=mCurrZero
MeasureName3=mCurrSec
X=306
Y=175
StringStyle=BOLD
StringAlign=CENTER
FontColor=255,255,255
FontSize=9
FontFace=#FontName#
AntiAlias=1
Text="%1:%2%3"

[MeterCurrentTrackArtist]
Meter=STRING
MeasureName=MeasureCurrentTrackArtist
X=230
Y=210
W=100
H=100
Clipstring=1
StringStyle=BOLD
StringAlign=CENTER
FontColor=255,255,255
FontSize=8
FontFace=#FontName#
AntiAlias=1
Text="%1"

[MeterCurrentTrackName]
Meter=STRING
MeasureName=MeasureCurrentTrackName
X=305
Y=190
W=300
H=100
Clipstring=1
StringStyle=BOLD
StringAlign=CENTER
FontColor=255,255,255
FontSize=10
FontFace=#FontName#
AntiAlias=1
Text="%1"

[MeterCurrentTrackAlbum]
Meter=String
MeasureName=MeasureCurrentTrackAlbum
X=383
Y=210
W=100
H=200
Clipstring=1
StringStyle=BOLD
StringAlign=CENTER
FontColor=255,255,255
FontSize=8
FontFace=#FontName#
AntiAlias=1
Text="%1"

--------------------------------------------------------------------------
--Button Measures--

[MeasurePrev]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=PreviousTrack

[MeasurePlay]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=Play

[MeasurePause]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=Pause

[MeasureNext]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=NextTrack

[MeasurePower]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=Power

[MeasureRewind]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=Rewind

[MeasureFastForward]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=FastForward

[MeasureVolumeDown]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=SoundVolumeDown

[MeasureVolumeUp]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=SoundVolumeUp

------------------------------------------------------------------------------
--Buttons--

[PrevInactive]
Meter=IMAGE
ImageName=backb.png
X=106
Y=286
W=35
H=35
LeftMouseDownAction=!execute [!RainmeterShowMeter PrevActive][!RainmeterRedraw]

[PrevActive]
Meter=IMAGE
ImageName=backb.png
X=106
Y=286
W=35
H=35
LeftMouseUpAction=!execute [!RainmeterPluginBang "MeasurePrev"][!RainmeterHideMeter PrevActive][!RainmeterRedraw]

[PlayInactive]
Meter=IMAGE
X=440
Y=250
W=35
H=35
ImageName=playb.png
LeftMouseDownAction=!execute [!RainmeterShowMeter PlayActive] [!RainmeterRedraw]


[PlayActive]
Meter=IMAGE
X=440
Y=250
W=35
H=35
ImageName=playb.png
LeftMouseUpAction=!execute [!RainmeterPluginBang "MeasurePlay"][!RainmeterHideMeter PlayActive][!RainmeterRedraw]


[PauseInactive]
Meter=IMAGE
X=130
Y=253
W=21
H=21
ImageName=pauseb.png
LeftMouseDownAction=!execute [!RainmeterShowMeter PauseActive] [!RainmeterRedraw]


[PauseActive]
Meter=IMAGE
X=130
Y=253
W=21
H=21
ImageName=pauseb.png
Hidden=1
LeftMouseUpAction=!execute [!RainmeterPluginBang "MeasurePause"][!RainmeterHideMeter PauseActive][!RainmeterRedraw]

[NextInactive]
Meter=IMAGE
X=461
Y=288
W=35
H=35
ImageName=forwardb.png
LeftMouseDownAction=!execute [!RainmeterShowMeter NextActive] [!RainmeterRedraw]

[NextActive]
Meter=IMAGE
X=461
Y=288
W=35
H=35
ImageName=forwardb.png
LeftMouseUpAction=!execute [!RainmeterPluginBang "MeasureNext"][!RainmeterHideMeter NextActive][!RainmeterRedraw]

[PowerActive]
Meter=IMAGE
X=450
Y=335
W=20
H=20
;ImageName=powerb.png
ImageName=#powericon#
measure=#onoroff#
ifequalValue=1
ifequalaction=!execute [!RainmeterPluginBang "MeasurePower"][!setVariable #onoroff# 0][!setVariable #powericon# powerg.png][!RainmeterRedraw]
ifbelowaction
ifBelowAction=!execute [!RainmeterPluginBang "MeasurePower"][!setVariable #onoroff# 1][!setVariable #powericon# powerb.png][!RainmeterRedraw]
;LeftMouseUpAction=!execute[!RainmeterPluginBang "MeasurePower"][!RainmeterRedraw]

[Audacity]
Meter=IMAGE
ImageName=musicb.png
X=130
Y=338
W=20
H=20
LeftMouseDownAction=!execute ["C:\Program Files (x86)\Audacity 1.3 Beta (Unicode)\audacity.exe"]

[volumeup]
Meter=IMAGE
ImageName=volumeupb.png
X=439
Y=370
W=20
H=20
LeftMouseUpAction=!execute [!RainmeterPluginBang "MeasureVolumeUp"][!RainmeterHideMeter NextActive][!RainmeterRedraw]

[volumeDown]
Meter=IMAGE
ImageName=volumedownb.png
X=140
Y=370
W=20
H=20
LeftMouseUpAction=!execute [!RainmeterPluginBang "MeasureVolumedown"][!RainmeterHideMeter NextActive][!RainmeterRedraw]
basically by default it will be set to off so powerb.png will be shown but once the power button is pressed i want the to change to powerg.png
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: If's and sorting image sources

Post by Mordasius »

p-k-y wrote:...new to this but have done plenty of coding before.
The basic problem you have with the script you posted is that "if - then" type statements which become something like IfEqualValue= and IfEqualAction= statements in Rainmeter can't be used in meters. They belong in measures. I suggest you take a look at this part of the rainmeter manual to see how such statements work in Rainmeter. If you still can't get it to work then you can always post whatever code you have and explain exactly what it is you want to do and I expect someone will help you sort it out.
p-k-y
Posts: 6
Joined: July 18th, 2012, 1:37 pm

Re: If's and sorting image sources

Post by p-k-y »

OK so its the measure that checks the power and issues the power command, but then im not sure if I can actually read a value as such to then use the actions on, am I wrong ?

Yea think im going to need a bit more thought and help with this than previously thought
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: If's and sorting image sources

Post by Mordasius »

Sorry, but I have no idea what you are trying to do. You are going to have to be a little more precise in the explanation of what you want to do.

Something like :- if I left-click on the meter [PowerActive] with these conditons .x, y z ... I want to show powerg.png or with the conditions ..x..y..z.. I want it to show powerb.png.
User avatar
UnforgivenRevival
Posts: 310
Joined: June 7th, 2012, 2:25 am
Location: Philadelphia, PA

Re: If's and sorting image sources

Post by UnforgivenRevival »

I believe they wants to make a "power" button, that shows when the player is open/closed. you may need an extra measure for this to tie to your power images.

EDIT: You may want to look into the Nowplaying.dll plugin. You can do alot more things with it like opening and closing the player with a bang and should help show when the player is open/closed.
Last edited by UnforgivenRevival on July 18th, 2012, 3:16 pm, edited 2 times in total.
p-k-y
Posts: 6
Joined: July 18th, 2012, 1:37 pm

Re: If's and sorting image sources

Post by p-k-y »

ok so if i press the power button [power active] and the power to itunes is off (itunes isnt open) then the white power image (powerb.png) is replaced with the greyed out power button (powerg.png) but it is still the same object. then if pressed when itunes is on it will pause it and close it (thats the next stage) and change the power button back to white.

Is that clear enough ? im not good at explaining things lol
User avatar
UnforgivenRevival
Posts: 310
Joined: June 7th, 2012, 2:25 am
Location: Philadelphia, PA

Re: If's and sorting image sources

Post by UnforgivenRevival »

You may need to use this to show when the application is open:

Code: Select all

[PlayerOnOff]
Plugin=AdvancedCPU
CPUInclude=itunes.exe
ifequalavalue=1
ifequalaction=[!setvariable image imagename.png]
IfBelowvalue=1
Ifbelowaction=[!setvariable image imagename2.png]
And then for your power meter, tie it to the variable,

Code: Select all

[MeterPlayerOnOff]
imagename=#image#


I have not tested this, so I do not know if this will work, but its a step in the right direction.