It is currently October 26th, 2021, 12:34 pm

Help me: Using PowerPlugin

Help with creating, editing & fixing problems with skins
daniel1229
Posts: 2
Joined: August 30th, 2021, 12:01 pm

Help me: Using PowerPlugin

Post by daniel1229 »

I want to change an image displayed on background from "heart_battery.png" to "charging.png" only when my laptop is plugged in.
the .png files are in "C:\Users\(Username)\Documents\Rainmeter\Skins\Heart Pixel Battery\Shares\"

Code: Select all

[Variables]
batteryBarFront="#SKINSPATH#\Heart Pixel Battery\Shares\heart_battery.png"
batteryBarBack="#SKINSPATH#\Heart Pixel Battery\Shares\heart_backframe.png"


[MeasurePowerSource]
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=ACLINE
IfEqualValue=1
IfEqualAction=[!SetVariable Variables batteryBarFront "#SKINSPATH\Heart Pixel Battery\Shares\charging.png"][!Redraw]
IfBelowValue=1
IfBelowAction=[!SetVariable Variables batteryBarFront "#SKINSPATH\Heart Pixel Battery\Shares\heart_battery.png"][!Redraw]
DynamicVariables=1

[MeasurePercent]
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=PERCENT
UpdateDivider=60


[barFront]
MeasureName=MeasurePercent
Meter=BAR
BarOrientation=HORIZONTAL
BarImage=#batteryBarFront#

[barBack]
Meter=Image
ImageName=#batteryBarBack#

not working. what's wrong with the code? help me
Last edited by balala on August 30th, 2021, 12:30 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are posting code snippets. It's the </> button.
User avatar
jsmorley
Developer
Posts: 22374
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help me: Using PowerPlugin

Post by jsmorley »

Add DynamicVariables=1 to both of those meters. You can actually remove it from the plugin measure.
User avatar
balala
Rainmeter Sage
Posts: 13346
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help me: Using PowerPlugin

Post by balala »

daniel1229 wrote: August 30th, 2021, 12:29 pm not working. what's wrong with the code? help me
There are more problems with the IfEqualAction and IfBelowAction options of the [MeasurePowerSource] measure:
  • The #SKINSPATH# variables are missing their last #. Add them back.
  • The used !SetVariable bangs are wrong. As you're using them they should be !SetOption bangs, but to modify a variable, the !SetVariable is required. This !SetVariable bang is requiring (usually) two parameters: the name of the variable you want to modify and the value you want to assign to the variable. Don't have to use the Variables section name.
  • See jsmorley's reply above, adding the DynamicVariables=1 option as he suggested.
  • Finally even if this is not a problem, redrawing a skin without updating the measures where the variable(s) is/are used makes no sense. Accordingly add the [!UpdateMeter "barFront"] bang next to [!Redraw]
Accordingly the [MeasurePowerSource] measure should look something like this:

Code: Select all

[MeasurePowerSource]
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=ACLINE
IfEqualValue=1
IfEqualAction=[!SetVariable batteryBarFront "#SKINSPATH#\Heart Pixel Battery\Shares\charging.png"][!UpdateMeter "barFront"][!Redraw]
IfBelowValue=1
IfBelowAction=[!SetVariable batteryBarFront "#SKINSPATH#\Heart Pixel Battery\Shares\heart_battery.png"][!UpdateMeter "barFront"][!Redraw]
DynamicVariables=1
daniel1229
Posts: 2
Joined: August 30th, 2021, 12:01 pm

Re: Help me: Using PowerPlugin

Post by daniel1229 »

balala wrote: August 30th, 2021, 12:42 pm There are more problems with the IfEqualAction and IfBelowAction options of the [MeasurePowerSource] measure:
  • The #SKINSPATH# variables are missing their last #. Add them back.
  • The used !SetVariable bangs are wrong. As you're using them they should be !SetOption bangs, but to modify a variable, the !SetVariable is required. This !SetVariable bang is requiring (usually) two parameters: the name of the variable you want to modify and the value you want to assign to the variable. Don't have to use the Variables section name.
  • See jsmorley's reply above, adding the DynamicVariables=1 option as he suggested.
  • Finally even if this is not a problem, redrawing a skin without updating the measures where the variable(s) is/are used makes no sense. Accordingly add the [!UpdateMeter "barFront"] bang next to [!Redraw]
Accordingly the [MeasurePowerSource] measure should look something like this:

Code: Select all

[MeasurePowerSource]
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=ACLINE
IfEqualValue=1
IfEqualAction=[!SetVariable batteryBarFront "#SKINSPATH#\Heart Pixel Battery\Shares\charging.png"][!UpdateMeter "barFront"][!Redraw]
IfBelowValue=1
IfBelowAction=[!SetVariable batteryBarFront "#SKINSPATH#\Heart Pixel Battery\Shares\heart_battery.png"][!UpdateMeter "barFront"][!Redraw]
DynamicVariables=1

Now Working! Thanks a lot!!!
User avatar
balala
Rainmeter Sage
Posts: 13346
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help me: Using PowerPlugin

Post by balala »

daniel1229 wrote: August 30th, 2021, 1:05 pm Now Working! Thanks a lot!!!
Great! :thumbup: