It is currently March 29th, 2024, 3:45 pm

How to !Refresh Skin if Connection state changes?

Get help with creating, editing & fixing problems with skins
NoGoodName
Posts: 5
Joined: April 3rd, 2018, 8:41 am

How to !Refresh Skin if Connection state changes?

Post by NoGoodName »

Hello,
Is it Possible to Refresh my Skin only if the Networkconnection changes state from online to offline or offline to online?
I'm useing Checknet to change some vars per !WriteKeyValue but if I do a Refresh in Online state and Offline State the Skin don't stop refreshing and I want it to do it only if the state changes. I also tried it with the "OnChangeAction" but it keeps refreshing everytime the Measure is updated. Thanks for any Help and suggestion :D
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to !Refresh Skin if Connection state changes?

Post by balala »

NoGoodName wrote:Hello,
Is it Possible to Refresh my Skin only if the Networkconnection changes state from online to offline or offline to online?
I'm useing Checknet to change some vars per !WriteKeyValue but if I do a Refresh in Online state and Offline State the Skin don't stop refreshing and I want it to do it only if the state changes. I also tried it with the "OnChangeAction" but it keeps refreshing everytime the Measure is updated. Thanks for any Help and suggestion :D
Post the code, please.
NoGoodName
Posts: 5
Joined: April 3rd, 2018, 8:41 am

Re: How to !Refresh Skin if Connection state changes?

Post by NoGoodName »

I've found the Problem.
My First though:

Code: Select all

[MeasureInternet]
Measure=Plugin
Plugin=CheckNet
ConnectionType=Internet
IfBelowValue=0
IfBelowAction=[!WriteKeyValue Variables DE #*ErrorDE*#] [!WriteKeyValue Variables EN #*ErrorEN*#] [!SetOption Schalter-DE hidden 0] [!SetOption Schalter-EN hidden 0] [!UpdateMeasureGroup Text] [!SetOptionGroup Klick MouseActionCursor 0] [!SetOptionGroup Klick LeftMouseUpAction []]
DynamicVariables=1
IfAboveValue=0
IfAboveAction=[!WriteKeyValue Variables DE #*deDE*#] [!WriteKeyValue Variables EN #*enEN*#] [!SetOption Schalter-DE hidden 0] [!SetOption Schalter-EN hidden 0] [!SetOption Schalter-EN hidden 0] [!UpdateMeasureGroup Text]
UpdateDivider=20
OnChangeAction=[!Refresh]
The Solution:

Code: Select all

[MeasureInternet]
Measure=Plugin
Plugin=CheckNet
ConnectionType=Internet
IfBelowValue=0
IfBelowAction=[!WriteKeyValue Variables DE #*ErrorDE*#] [!WriteKeyValue Variables EN #*ErrorEN*#] [!SetOption Schalter-DE hidden 0] [!SetOption Schalter-EN hidden 0] [!UpdateMeasureGroup Text] [!SetOptionGroup Klick MouseActionCursor 0] [!SetOptionGroup Klick LeftMouseUpAction []][b] [!SetOption MeasureInternet OnChangeAction [!Refresh]][/b]
DynamicVariables=1
IfAboveValue=0
IfAboveAction=[!WriteKeyValue Variables DE #*deDE*#] [!WriteKeyValue Variables EN #*enEN*#] [!SetOption Schalter-DE hidden 0] [!SetOption Schalter-EN hidden 0] [!SetOption Schalter-EN hidden 0] [!UpdateMeasureGroup Text] [!SetOption MeasureInternet OnChangeAction [!Refresh]]
UpdateDivider=20
Thanks for the replie :)
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to !Refresh Skin if Connection state changes?

Post by balala »

NoGoodName wrote:I've found the Problem.
My First though:

The Solution:
I'm glad, however take care that you can't use the bold tags in the posted code.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to !Refresh Skin if Connection state changes?

Post by jsmorley »

I think the idea should actually be pretty simple.

Code: Select all

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

[MeasureConnect]
Measure=Plugin
Plugin=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
;SysInfoType=LAN_CONNECTIVITY
SysInfoData=Best
OnChangeAction=[!Log "State Changed"]

[MeterDummy]
Meter=String
When the skin is first loaded or when it is refreshed, there will be an "initial" value for [MeasureConnect] that is set during the first update of the skin. That will not trigger OnChangeAction, which will only be triggered if and when the connection state changes after that.

P.S. The CheckNet plugin was written before SysInfo supported this, and I'd be tempted to use the built-in SysInfo rather than the 3rd-party CheckNet.
TheFaIIen1ne
Posts: 1
Joined: March 4th, 2020, 8:03 am

Re: How to !Refresh Skin if Connection state changes?

Post by TheFaIIen1ne »

Hey guys!!! i too am a new member to this thing and i need your help. i have got the visualizer from simple epoca. i have tweaked it a little bit to suit my needs, but the problem arises whenever i change my audio device. say from my laptop speakers to my Bluetooth speakers. i know that whenever one does this he needs to refresh the skin but i was looking for any automated options. so i came by this post and this looks very promising. so just as you guys did for the condition of a network change ca you show me how to do for the condition of audio device change.
here is my code, pls do the necessary changes.

Code: Select all

[Rainmeter]
Update=0
Author=Connect-R
BackgroundMode=2
SolidColor=0,0,0,1

[Variables]
@include=#@#Variables.inc
AverageSize=2
;-------------------------------------------------------------
;-------------------------------------------------------------

------------------------------------------------------------
[MeasureAudioOutput]
Measure=Plugin
Plugin=AudioLevel
Port=Output
FFTSize=2048
FFTOverlap=1024
FFTAttack=350
FFTDecay=120
FreqMin=20
FreqMax=40000
Bands=27
Sensitivity=37

[MeasureAudioBarOutput]
Measure=Plugin
Plugin=AudioLevel
Port=Output
FFTSize=256
FFTOverlap=128
FFTAttack=100
FFTDecay=200
FreqMin=20
FreqMax=40000
Bands=2
Sensitivity=50

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeterStyleL]
BarOrientation=Horizontal
BarImage=#@#DotS1.png
X=90
Y=20r
Flip=1
ImageTint=255,255,255

[MeterStyleR]
BarOrientation=Horizontal
X=0
Y=20r
W=200
H=4
Flip=1
BarColor=255,255,255,40

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeasureAudioProcessor]
Measure=Plugin
Plugin=AudioLevel
Port=Output
Parent=MeasureAudioBarOutput
Type=Band
BandIdx=0
Channel=Avg
AverageSize=#AverageSize#

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeasureBand01]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
Channel=Avg
Type=Band
BandIdx=1
AverageSize=#AverageSize#

[MeasureBand02]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
Channel=Avg
Type=Band
BandIdx=2
AverageSize=#AverageSize#

[MeasureBand03]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
Channel=Avg
Type=Band
BandIdx=3
AverageSize=#AverageSize#
;-------------------------------------------------------------
;-------------------------------------------------------------

[MeterBandL_1]
Meter=Bar
MeterStyle=MeterStyleL
MeasureName=MeasureBand01
X=90
Y=100

[MeterBandL_2]
Meter=Bar
MeterStyle=MeterStyleL
MeasureName=MeasureBand02

[MeterBandL_3]
Meter=Bar
MeterStyle=MeterStyleL
MeasureName=MeasureBand03

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeterRhytmicBar]
Meter=Bar
MeasureName=MeasureAudioProcessor
BarOrientation=Vertical
BarColor=255,255,255,150
X=210
Y=20
H=340
W=2
DynamicVariables=1

[MeterRhytmicBar2]
Meter=Bar
MeasureName=MeasureAudioProcessor
BarColor=255,255,255,150
X=210
Y=360
H=340
W=2
Flip=1
DynamicVariables=1
Last edited by balala on March 4th, 2020, 9:17 am, edited 1 time in total.
Reason: Please use <code> tags whenever are you posting code snippets. It's the </> button.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to !Refresh Skin if Connection state changes?

Post by balala »

TheFaIIen1ne wrote: March 4th, 2020, 8:15 am so just as you guys did for the condition of a network change ca you show me how to do for the condition of audio device change.
Try to add a Win7Audio plugin measure, which returns (through its string value), the name of the current sound device. When this is changing, you should refresh.
So, add the following measure:

Code: Select all

[MeasureWin7Audio]
Measure=Plugin
Plugin=Win7AudioPlugin
Unfortunately this measure beside the name of the sound device (returned as a string), also returns the percentage of current volume level (as number). So, theoretically you should have to add an OnChangeAction option to the above measure, to get the skin refreshed, whenever the sound device is changing. But if you do this, the skin will be refreshed not just when the sound device is changing, but also when you set the volume (because although such in a case the sound device doesn't change, so the string value returned by the measure also doesn't change, the numeric value is changing, as the volume is changing). To avoid this, you'll need one more, this time a String, measure. Add it as well:

Code: Select all

[MeasureAudioDevice]
Measure=String
String=[MeasureWin7Audio]
OnChangeAction=[!Refresh]
DynamicVariables=1
Because the above String measure doesn't care about the volume level, this doesn't change when you change the volume, just when the sound device is changing as well. Such in a case, the OnChangeAction is executed, causing the refresh of the skin.
User avatar
Yincognito
Rainmeter Sage
Posts: 7031
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to !Refresh Skin if Connection state changes?

Post by Yincognito »

balala wrote: March 4th, 2020, 4:52 pmUnfortunately this measure beside the name of the sound device (returned as a string), also returns the percentage of current volume level (as number). So, theoretically you should have to add an OnChangeAction option to the above measure, to get the skin refreshed, whenever the sound device is changing. But if you do this, the skin will be refreshed not just when the sound device is changing, but also when you set the volume (because although such in a case the sound device doesn't change, so the string value returned by the measure also doesn't change, the numeric value is changing, as the volume is changing). To avoid this...
Just an idea: couldn't this be also done using an IfMatch option where you test the current string value of the measure against a (hypothetical) string variable where you store the last (string) value of the measure? Taking care, of course, to update that variable once you're done with the bangs?

Actually, if I think about it, your way is better and clearer, since in my variant, additional "inconveniences" may arise from IfMatch being triggered on the first update of the measure as well (although this could be the desired behavior in some scenarios, after all)...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to !Refresh Skin if Connection state changes?

Post by balala »

Yincognito wrote: March 4th, 2020, 6:34 pm Just an idea: couldn't this be also done using an IfMatch option where you test the current string value of the measure against a (hypothetical) string variable where you store the last (string) value of the measure?
Definitely could be. As usually there are more ways to achieve the same result. Mine was one of them, this is another.
However note one minor detail: I didn't use a string variable, but a String measure. Just to be precise...
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to !Refresh Skin if Connection state changes?

Post by balala »

TheFaIIen1ne wrote: March 4th, 2020, 8:15 am

Code: Select all

[Rainmeter]
Update=0
Author=Connect-R
BackgroundMode=2
SolidColor=0,0,0,1
Note that:
  • Update=0 is completely wrong. The lowest possible value of Update is 16 (second paragraph here) and no way to be 0.
  • Although once the Author option belonged to the [Rainmeter] section, in meantime it has been moved to [Metadata]. Move it as well.