It is currently April 26th, 2024, 2:53 pm

[Solved] Switch button / external script result

Get help with creating, editing & fixing problems with skins
YPO
Posts: 3
Joined: May 15th, 2021, 8:10 am

[Solved] Switch button / external script result

Post by YPO »

Hello everyone !

I need a little bit of help to create my first skin.
  • What I want to do:
    A switch button to activate/deactivate Wifi MAC Filter.
    (I have 2 python scripts that work well : one to get the filter status, and another one to switch it ON/OFF.)
    It should work that way:
    • Have the "get filter status" python script run every 10 sec.
    • Display an image depending on that python script result.
    • Execute the "filter switch" script when clicking on that image.
  • What my rainmeter looks like at the moment (there are certainly a lot of things I don't do the right way, but I'm ready to learn!):

Code: Select all

[Rainmeter]
Update=10000
DynamicWindowSize=1
AccurateText=1


[getFilter]
;how can I run this every 10 seconds?
Measure=Plugin
Plugin=RunCommand
Parameter=python.exe #@#Scripts\getFilter.py
State=Hide

[switchFilter]
Measure=Plugin
Plugin=RunCommand
Parameter=python.exe #@#Scripts\switchFilter.py
State=Hide

[MeasureImage]
MeasureName=getFilter
IfMatch=True
IfMatchAction=[!SetOption MeterImage ImageName #@#Images\wifiON.ico]
IfMatchAction=[!SetOption MeterImage ImageName #@#Images\wifiOFF.ico]
;IfMatchMode=1

[MeterImage]
Meter=Image
;default image to be displayed at the beginnig in case getFilter did not run yet
ImageName=#@#Images\wifi.ico
W=32
H=32
X=0
Y=0
LeftMouseUpAction=[!CommandMeasure switchFilter "Run"]
Thanks in advande for you help! :D
Last edited by YPO on May 15th, 2021, 12:29 pm, edited 4 times in total.
YPO
Posts: 3
Joined: May 15th, 2021, 8:10 am

Re: Switch button / external script result

Post by YPO »

I forgot to mention
  • what works:
    • The default image loads correctly (#@#Images\wifi.ico)
    • When I click on it, the "switch filter" is executed correctly
  • and what doesn't work:
    • The "get filter status" script is never executed
    • Obviously, the image doesn't change
YPO
Posts: 3
Joined: May 15th, 2021, 8:10 am

Re: Switch button / external script result

Post by YPO »

Finally solved it by myself. :D
I corrected a few things:
  • put the if/else in [getFilter] measure;
  • removed the [measureImage] section;
  • added OnUpdateAction in [Rainmeter] section.
Don't know if that can help, but I put my final code here:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnUpdateAction=[!CommandMeasure "getFilter" "Run"]

[getFilter]
UpdateDivider=1
Measure=Plugin
Plugin=RunCommand
Parameter=python.exe #@#Scripts\getFilter.py
State=Hide
OutputType=ANSI
IfMatch=True
IfMatchAction=[!SetOption MeterImage ImageName #@#Images\wifiON.ico]
IfNotMatchAction=[!SetOption MeterImage ImageName #@#Images\wifiOFF.ico]

[switchFilter]
Measure=Plugin
Plugin=RunCommand
Parameter=python.exe #@#Scripts\switchFilter.py
State=Hide

[MeterImage]
Meter=Image
ImageName=#@#Images\wifi.ico
W=32
H=32
X=0
Y=0
LeftMouseUpAction=[!CommandMeasure switchFilter "Run"]
[\code]