It is currently April 19th, 2024, 2:38 pm

VPN Status Skin refresh help

Get help with creating, editing & fixing problems with skins
NocodeExp
Posts: 7
Joined: February 16th, 2019, 3:55 am

VPN Status Skin refresh help

Post by NocodeExp »

I've been working [ aka: stitching code together ] to create a VPN status indicator to help me remember to log off when I'm done working. I work with multiple clients, so I created a monitor for each. The issue is that it doesn't seem to be refreshing properly, so it doesn't detect when I connect and disconnect unless I manually refresh.

I used a combination of an existing skin for formatting and mixed with some older code I found for monitoring the VPN status. I'm just struggling with it not refreshing, even though I have the update set correctly. I thought I would reach out to the Rainmeter community for some assistance.

I posted my code for this here for your review/testing.
Thanks in advance.

Code: Select all

; Lines starting ; (semicolons) are commented out.
; That is, they do not affect the code and are here for demonstration purposes only.
; ----------------------------------

[Rainmeter]
; This section contains general settings that can be used to change how Rainmeter behaves.
Update=1000
Background=#@#Background.png
; #@# is equal to Rainmeter\Skins\illustro\@Resources
BackgroundMode=3
BackgroundMargins=0,34,0,14

[Metadata]
; Contains basic information of the skin.
Name=VPN Status

[Variables]
; Variables declared here can be used later on between two # characters (e.g. #MyVariable#).
fontName=Trebuchet MS
textSize=8
colorBar=235,170,0,255
colorText=255,255,255,205

; ----------------------------------
; MEASURES return some kind of value
; ----------------------------------


[MeasureVPN1]
Measure=Plugin
Plugin=SysInfo
SysInfoData="VPN_1"
;Name of VPN adapter
SysInfoType=ADAPTER_DESCRIPTION
Substitute="VPN_1":"1"

[MeasureVPN2]
Measure=Plugin
Plugin=SysInfo
SysInfoData="VPN_2"
;Name of VPN adapter
SysInfoType=ADAPTER_DESCRIPTION
Substitute="VPN_2":"1"

; ----------------------------------
; STYLES are used to "centralize" options
; ----------------------------------

[styleTitle]
StringAlign=Center
StringCase=Upper
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,50
FontColor=#colorText#
FontFace=#fontName#
FontSize=10
AntiAlias=1
ClipString=1

[styleLeftText]
StringAlign=Left
; Meters using styleLeftText will be left-aligned.
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleRightText]
StringAlign=Right
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleBar]
BarColor=#colorBar#
BarOrientation=HORIZONTAL
SolidColor=255,255,255,15

; ----------------------------------
; METERS display images, text, bars, etc.
; ----------------------------------

[meterTitle]
Meter=String
MeterStyle=styleTitle
; Using MeterStyle=styleTitle will basically "copy" the
; contents of the [styleTitle] section here during runtime.
X=100
Y=12
W=190
H=18
Text=VPN Status
; Even though the text is set to System, Rainmeter will display
; it as SYSTEM, because styleTitle contains StringCase=Upper.
LeftMouseUpAction=["taskmgr.exe"]
; Left-clicking this meter will launch taskmgr.exe (the Task Manager).
ToolTipText=Open Task Manager
; Hovering over this meter will display a tooltip with the text above.


; ----------------------------------
; VPN VPN display images, text, bars, etc.
; ----------------------------------

[meterLabelVPN1]
Meter=String
MeterStyle=styleLeftText
X=10
Y=40
W=190
H=14
Text=VPN_1



[OnlineStatus1]
Measure=Calc
Formula=[MeasureVPN1]
IfCondition=OnlineStatus1 = 1
IfTrueAction=[!SetOption MeterValueVPN1 FontColor 0,255,0,155][!Redraw]
IfCondition=OnlineStatus1 <> 1
IfTrueAction=[!SetOption MeterValueVPN1 FontColor 0,0,0,90][!Redraw]

[MeterValueVPN1]
Meter=String
MeterStyle=styleRightText
MeasureName=OnlineStatus1
FontColor=0,0,0,90
X=200
Y=0r
W=190
H=14

Text=ACTIVE


[meterBarVPN1]
Meter=Bar
MeterStyle=styleBar
MeasureName=OnlineStatus1
X=10
Y=52
W=190
H=1


[meterLabelVPN2]
Meter=String
MeterStyle=styleLeftText


X=10
Y=60
W=190
H=14
Text=VPN_2


[OnlineStatus2]
Measure=Calc
Formula=[MeasureVPN2]
IfCondition=OnlineStatus2 = 1
IfTrueAction=[!SetOption MeterValueVPN2 FontColor 0,255,0,155][!Redraw]
IfCondition=OnlineStatus2 <> 1
IfTrueAction=[!SetOption MeterValueVPN2 FontColor 0,0,0,90][!Redraw]


[MeterValueVPN2]
Meter=String
MeterStyle=styleRightText
MeasureName=OnlineStatus2
FontColor=0,0,0,90
X=200
Y=0r
W=190
H=14

Text=ACTIVE


[meterBarVPN2]
Meter=Bar
MeterStyle=styleBar
MeasureName=OnlineStatus2
X=10
Y=72
W=190
H=1
Last edited by NocodeExp on February 18th, 2019, 12:32 am, edited 2 times in total.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5393
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: VPN Status Skin refresh hep

Post by eclectic-tech »

You did not increment your IfCondition statements. They must be uniquely numbered; duplicate statements are ignored.

Modify your status check sections:

Code: Select all

[OnlineStatus1]
Measure=Calc
Formula=[MeasureVPN1]
IfCondition=OnlineStatus1 = 1
IfTrueAction=[!SetOption MeterValueVPN1 FontColor 0,255,0,155][!Redraw]
IfCondition2=OnlineStatus1 <> 1
IfTrueAction2=[!SetOption MeterValueVPN1 FontColor 0,0,0,90][!Redraw]
And

Code: Select all

[OnlineStatus2]
Measure=Calc
Formula=[MeasureVPN2]
IfCondition=OnlineStatus2 = 1
IfTrueAction=[!SetOption MeterValueVPN2 FontColor 0,255,0,155][!Redraw]
IfCondition2=OnlineStatus2 <> 1
IfTrueAction2=[!SetOption MeterValueVPN2 FontColor 0,0,0,90][!Redraw]
I do not use VPN and cannot test, but a final option, if it is still not responding, would be to add IfConditionMode=1 to these sections. It forces a test even if the condition has not changed.
NocodeExp
Posts: 7
Joined: February 16th, 2019, 3:55 am

Re: VPN Status Skin refresh hep

Post by NocodeExp »

Thanks for the quick response. Unfortunately that did not resolve the check again issue.

The issue remains that the skin does not update when the condition changes. I can see the measures in the Skins log, so the conditioning being used should work, but it's only changing the skin on a manual refresh.
VPN Status.PNG
You do not have the required permissions to view the files attached to this post.
Last edited by NocodeExp on February 17th, 2019, 9:55 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: VPN Status Skin refresh hep

Post by balala »

NocodeExp wrote: February 17th, 2019, 9:30 pm I'm not able to find documentation on [ IfconditionsMode ] as you mentioned, so I'm not sure how to use it.
https://docs.rainmeter.net/manual-beta/measures/general-options/ifconditions/#IfConditionMode
NocodeExp
Posts: 7
Joined: February 16th, 2019, 3:55 am

Re: VPN Status Skin refresh hep

Post by NocodeExp »

Just found it and pulled that out of my post... Thanks :D
NocodeExp
Posts: 7
Joined: February 16th, 2019, 3:55 am

Re: VPN Status Skin refresh hep

Post by NocodeExp »

it appears that the Update function does not cause the Measure to refresh. I used a leftmouseupaction to force an update of all measures/meters involved and I do not get a change in status. However, if I use a [!Refresh] on this action, it does update correctly.

I don't want to have to click the Skin to update it each time, kind of defeats the purpose of having it.

This seems like it should be so simple... grrr
NocodeExp
Posts: 7
Joined: February 16th, 2019, 3:55 am

Re: VPN Status Skin refresh hep

Post by NocodeExp »

Update

Using the below settings, I can force a refresh while the VPN is connected to check to see if it's not and this works to turn the light off. However, I'm still stuck at my original issue, the update function is not re-checking the Sysinfo for updates, so I have programmatically confirmed my problem. Sysinfo does not update when the skin updates, only on a refresh.


[OnlineStatus1]
Measure=calc
Formula=[MeasureVPN1]
IfCondition=OnlineStatus1=1
IfTrueAction=[!SetOption MeterValueVPN1 FontColor 0,255,0,155][!delay 1000][!refresh]
IfCondition1=OnLineStatus1 <> 1
IfTrueAction=[!delay 1000][!Refresh]
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: VPN Status Skin refresh hep

Post by jsmorley »

NocodeExp wrote: February 17th, 2019, 10:52 pm Update

Using the below settings, I can force a refresh while the VPN is connected to check to see if it's not and this works to turn the light off. However, I'm still stuck at my original issue, the update function is not re-checking the Sysinfo for updates, so I have programmatically confirmed my problem. Sysinfo does not update when the skin updates, only on a refresh.


[OnlineStatus1]
Measure=calc
Formula=[MeasureVPN1]
IfCondition=OnlineStatus1=1
IfTrueAction=[!SetOption MeterValueVPN1 FontColor 0,255,0,155][!delay 1000][!refresh]
IfCondition1=OnLineStatus1 <> 1
IfTrueAction=[!delay 1000][!Refresh]

That code is a certain endless loop of refreshes.
NocodeExp
Posts: 7
Joined: February 16th, 2019, 3:55 am

Re: VPN Status Skin refresh help

Post by NocodeExp »

I know it loops, but I do not know how to refresh the sysinfo data any other way.
The Update setting does not re-poll the SysInfo data needed for this to work correctly.

So, I have this working, using the code below, but as stated.. endless loop and Notices in the log files of each refresh.

If anyone can do this better without the loops and log entries ... I'm all ears. This is my first Skin to create and this is all new to me, so to get it working at all has been a fun weekend project for me.

All the help provided and any future assistance is 100% appreciated.

; Lines starting ; (semicolons) are commented out.
; That is, they do not affect the code and are here for demonstration purposes only.
; ----------------------------------

[Rainmeter]
; This section contains general settings that can be used to change how Rainmeter behaves.
Update=10000
Background=#@#Background.png

BackgroundMode=3
BackgroundMargins=0,34,0,14


[Metadata]
; Contains basic information of the skin.
Name=VPN Status

[Variables]
; Variables declared here can be used later on between two # characters (e.g. #MyVariable#).
fontName=Trebuchet MS
textSize=8
colorBar=235,170,0,255
colorText=255,255,255,205



; ----------------------------------
; MEASURES return some kind of value
; ----------------------------------


[MeasureVPN1]
Measure=Plugin
Plugin=SysInfo
SysInfoData="VPN1"
SysInfoType=ADAPTER_DESCRIPTION
Substitute="VPN1":"1","Realtek PCIe GBE Family Controller":"0"

IfCondition=MeasureVPN1 = 1
IfTrueAction=[!Delay 5000][!Refresh]

IfCondition2=MeasureVPN1 = 0
IfTrueAction2=[!Delay 5000][!Refresh]
OnUpdateAction=[!UpdateMeasure OnlineStatus1]

[MeasureVPN2]
Measure=Plugin
Plugin=SysInfo
SysInfoData="VPN_2"
SysInfoType=ADAPTER_DESCRIPTION
Substitute="VPN_2":"1","Realtek PCIe GBE Family Controller":"0"


IfCondition=MeasureVPN2 = 1
IfTrueAction=[!UpdateMeasure OnlineStatus2]

IfCondition2=MeasureVPN2 = 0
IfTrueAction2=[!UpdateMeasure OnlineStatus2]
OnUpdateAction=[!UpdateMeasure OnlineStatus2]

; ----------------------------------
; STYLES are used to "centralize" options
; ----------------------------------

[styleTitle]
StringAlign=Center
StringCase=Upper
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,50
FontColor=#colorText#
FontFace=#fontName#
FontSize=10
AntiAlias=1
ClipString=1

[styleLeftText]
StringAlign=Left
; Meters using styleLeftText will be left-aligned.
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleRightText]
StringAlign=Right
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleBar]
BarColor=#colorBar#
BarOrientation=HORIZONTAL
SolidColor=255,255,255,15

; ----------------------------------
; METERS display images, text, bars, etc.
; ----------------------------------

[meterTitle]
Meter=String
MeterStyle=styleTitle
; Using MeterStyle=styleTitle will basically "copy" the
; contents of the [styleTitle] section here during runtime.
X=100
Y=12
W=190
H=18
Text=VPN Status
; Even though the text is set to System, Rainmeter will display
; it as SYSTEM, because styleTitle contains StringCase=Upper.
LeftMouseUpAction=["taskmgr.exe"]
; Left-clicking this meter will launch taskmgr.exe (the Task Manager).
ToolTipText=Open Task Manager
; Hovering over this meter will display a tooltip with the text above.


; ----------------------------------
; VPN VPN display images, text, bars, etc.
; ----------------------------------



[meterLabelVPN1]
Meter=String
MeterStyle=styleLeftText
X=10
Y=40
W=190
H=14
Text=VPN_1


[OnlineStatus1]
Measure=calc
Formula=[MeasureVPN1]
IfCondition=OnlineStatus1=1
IfTrueAction=[!SetOption MeterValueVPN1 FontColor 0,255,0,155]
IfCondition1=OnLineStatus1 = 0
IfTrueAction1=[!SetOption MeterValueVPN1 FontColor 0,0,0,90]


[MeterValueVPN1]
Meter=String
MeterStyle=styleRightText
MeasureName=OnlineStatus1
FontColor=0,0,0,90
X=200
Y=0r
W=190
H=14

Text=ACTIVE


[meterBarVPN1]
Meter=Bar
MeterStyle=styleBar
MeasureName=OnlineStatus1
X=10
Y=52
W=190
H=1


[meterLabelVPN2]
Meter=String
MeterStyle=styleLeftText


X=10
Y=60
W=190
H=14
Text=VPN_2


[OnlineStatus2]
Measure=Calc
Formula=[MeasureVPN2]
IfCondition=OnlineStatus2=1
IfTrueAction=[!SetOption MeterValueVPN2 FontColor 0,255,0,155]
IfCondition1=OnLineStatus2 = 0
IfTrueAction1=[!SetOption MeterValueVPN2 FontColor 0,0,0,90]


[MeterValueVPN2]
Meter=String
MeterStyle=styleRightText
MeasureName=OnlineStatus2
FontColor=0,0,0,90
X=200
Y=0r
W=190
H=14

Text=ACTIVE


[meterBarVPN2]
Meter=Bar
MeterStyle=styleBar
MeasureName=OnlineStatus2
X=10
Y=72
W=190
H=1
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5393
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: VPN Status Skin refresh help

Post by eclectic-tech »

You set a skin update of 10 seconds... to reduce the timig of your looping refresh; I reset it to 1000 ms.

You mixed up the IfCondition numbering in your second set of measures [OnlineStatus1] & [OnlineStatus2] ... "IfCondition1=..." should be "IfCondition2=...", "IfCondition3=...", etc.

But in looking at your code, you are
1) checking the value of the sysinfo adapter label
2) replacing that with a number
3) using that number to try to refresh
4) using that value in 2 new measures to check the number value again
5) using that result to set a color value
6) not updating or redrawing anything
... that is just overkill.

I moved the font color changes to your initial VPN measures and removed the Status measure completely. Those measures are really not needed, you can take those actions in the first 2 measures [MeasureVPN1] & [MeasureVPN2]. In order to see the changes to meter options, you should update the meters and redraw them.

Try this modified code with those changes (No VPN here so you will need to test):

Code: Select all

; Lines starting ; (semicolons) are commented out.
; That is, they do not affect the code and are here for demonstration purposes only.
; ----------------------------------

[Rainmeter]
; This section contains general settings that can be used to change how Rainmeter behaves.
Update=1000
Background=#@#Background.png

BackgroundMode=3
BackgroundMargins=0,34,0,14


[Metadata]
; Contains basic information of the skin.
Name=VPN Status

[Variables]
; Variables declared here can be used later on between two # characters (e.g. #MyVariable#).
fontName=Trebuchet MS
textSize=8
colorBar=235,170,0,255
colorText=255,255,255,205



; ----------------------------------
; MEASURES return some kind of value
; ----------------------------------


[MeasureVPN1]
Measure=Plugin
Plugin=SysInfo
SysInfoData="VPN1"
SysInfoType=ADAPTER_DESCRIPTION
Substitute="VPN1":"1","Realtek PCIe GBE Family Controller":"0"

IfCondition=MeasureVPN1 = 1
IfTrueAction=[!SetOption MeterValueVPN1 FontColor 0,255,0,155][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOption MeterValueVPN1 FontColor 0,0,0,90][!UpdateMeter *][!Redraw]
IfConditionMode=1

[MeasureVPN2]
Measure=Plugin
Plugin=SysInfo
SysInfoData="VPN_2"
SysInfoType=ADAPTER_DESCRIPTION
Substitute="VPN_2":"1","Realtek PCIe GBE Family Controller":"0"

IfCondition=MeasureVPN2 = 1
IfTrueAction=[!SetOption MeterValueVPN2 FontColor 0,255,0,155][!UpdateMeter *][!Redraw]
IfFalseAction1=[!SetOption MeterValueVPN2 FontColor 0,0,0,90][!UpdateMeter *][!Redraw]
IfConditionMode=1

; ----------------------------------
; STYLES are used to "centralize" options
; ----------------------------------

[styleTitle]
StringAlign=Center
StringCase=Upper
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,50
FontColor=#colorText#
FontFace=#fontName#
FontSize=10
AntiAlias=1
ClipString=1

[styleLeftText]
StringAlign=Left
; Meters using styleLeftText will be left-aligned.
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleRightText]
StringAlign=Right
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleBar]
BarColor=#colorBar#
BarOrientation=HORIZONTAL
SolidColor=255,255,255,15

; ----------------------------------
; METERS display images, text, bars, etc.
; ----------------------------------

[meterTitle]
Meter=String
MeterStyle=styleTitle
; Using MeterStyle=styleTitle will basically "copy" the
; contents of the [styleTitle] section here during runtime.
X=100
Y=12
W=190
H=18
Text=VPN Status
; Even though the text is set to System, Rainmeter will display
; it as SYSTEM, because styleTitle contains StringCase=Upper.
LeftMouseUpAction=["taskmgr.exe"]
; Left-clicking this meter will launch taskmgr.exe (the Task Manager).
ToolTipText=Open Task Manager
; Hovering over this meter will display a tooltip with the text above.


; ----------------------------------
; VPN VPN display images, text, bars, etc.
; ----------------------------------



[meterLabelVPN1]
Meter=String
MeterStyle=styleLeftText
X=10
Y=40
W=190
H=14
Text=VPN_1


[MeterValueVPN1]
Meter=String
MeterStyle=styleRightText
MeasureName=MeasureVPN1
FontColor=0,0,0,90
X=200
Y=0r
W=190
H=14

Text=ACTIVE


[meterBarVPN1]
Meter=Bar
MeterStyle=styleBar
MeasureName=MeasureVPN1
X=10
Y=52
W=190
H=1


[meterLabelVPN2]
Meter=String
MeterStyle=styleLeftText


X=10
Y=60
W=190
H=14
Text=VPN_2


[MeterValueVPN2]
Meter=String
MeterStyle=styleRightText
MeasureName=MeasureVPN2
FontColor=0,0,0,90
X=200
Y=0r
W=190
H=14

Text=ACTIVE


[meterBarVPN2]
Meter=Bar
MeterStyle=styleBar
MeasureName=MeasureVPN2
X=10
Y=72
W=190
H=1