This skin seems to work great to determine if the PIA VPN application is active or not. However it only updates on initial launch or manual refresh. If I turn the VPN off, it does not update the skin. And the reverse is true, if it correctly identifies that the VPN is off, then I start it, it does not reflect the new state in the skin. I left the default Update at 1000 but have tried other settings.
Last edited by balala on November 15th, 2020, 8:17 pm, edited 1 time in total.
Reason:Please use <code> tags whenever are posting code snippets. It's the </> button.
Darv wrote: ↑November 15th, 2020, 7:57 pm
This skin seems to work great to determine if the PIA VPN application is active or not. However it only updates on initial launch or manual refresh. If I turn the VPN off, it does not update the skin. And the reverse is true, if it correctly identifies that the VPN is off, then I start it, it does not reflect the new state in the skin. I left the default Update at 1000 but have tried other settings.
The [OnlineStatus] measure uses a section variable ([MeasureNetwork]) into its Formula option (Formula=[MeasureNetwork]). But such a section variable requires setting on the dynamic Variables. So add a DynamicVariables=1 option to this measure.
Additional note: since the [MeasureNetwork] measure returns both, a String and a numeric value, I'd use better its numeric value into Formula option of a Calc measure. In fact this option always works only with numeric values, so how have you set it is ok, however I recommend to explicitely say the measure to use numeric value. To do this replace the mentioned Formula option with Formula=[MeasureNetwork:].
Well, assuming I did everything right, it seems to have broke the script. But then I know very little of scripting skins.
Here is the skin. I am sure I did something wrong. Adding the: Formula=[MeasureNetwork:] seems to have broke it as it no longer is able to determine the status as anything but offline.
Darv wrote: ↑November 15th, 2020, 10:35 pm
Well, assuming I did everything right, it seems to have broke the script. But then I know very little of scripting skins.
Here is the skin. I am sure I did something wrong. Adding the: Formula=[MeasureNetwork:] seems to have broke it as it no longer is able to determine the status as anything but offline.
Since you are using Substitute to change the name of the adapter into a number, that is acting on the string value of the measure. So you want to use:
Formula=[MeasureNetwork]
And not:
Formula=[MeasureNetwork:]
Since using the : character in the section variable tells it to use the number value, which this measure won't have. The number value of the measure will always be 0.
jsmorley wrote: ↑November 15th, 2020, 10:51 pm
Since you are using Substitute to change the name of the adapter into a number, that is acting on the string value of the measure. So you want to use:
Formula=[MeasureNetwork]
And not:
Formula=[MeasureNetwork:]
Since using the : character in the section variable tells it to use the number value, which this measure won't have. The number value of the measure will always be 0.
Thanks! Yes, that explains why adding the Formula=[MeasureNetwork:] broke the script. The script now does detect the change from Off to On (turns the icon from Red to Green) but fails to turn the icon from On to OFF when turning the VPN off. So we are like 95% there. Adding the DynamicVariables=1 to the [OnlineStatus] seemed to fix the detection that the VPN had been turned on. Now I just need to get it to detect an Off state.
Thanks again for the help. Can you see any reason it wouldn't detect the VPN going off line?
Here is the current script.
Last edited by balala on November 16th, 2020, 7:18 am, edited 1 time in total.
Reason:Please use <code> tags whenever are posting code snippets. It's the </> button.
jsmorley wrote: ↑November 15th, 2020, 10:51 pm
Since you are using Substitute to change the name of the adapter into a number, that is acting on the string value of the measure. So you want to use:
Formula=[MeasureNetwork]
And not:
Formula=[MeasureNetwork:]
Since using the : character in the section variable tells it to use the number value, which this measure won't have. The number value of the measure will always be 0.
I used your code and it seems to work exactly the same.
1) PIA = OFF - Launching skin correctly shows RED.
2) PIA = ON - Launch PIA and connect skin changes to GREEN.
3) PIA = OFF - Turn PIA off and skin remains GREEN (Should change to RED)
4) PIA = ON - Launch skin turns GREEN
So only item #3 fails to detect that PIA has been turned off. I am completely baffled. If item #1 is detecting PIA=OFF and it gets re-run every 1 second why isn't it detecting that PIA has been turned off?
I really do appreciate all the work you put into it. The code seems to make sense to me but fails to function as it should.
If you have any further ideas, please do let me know. I hate to give up on this. I know for a fact it can work.
Okay, good news. The script did not know how to deal with the default ADAPTER_DESCRIPTION because the Substitute did not assign it a numeric value. So it was seeing the string for the Intel(R) Ethernet Connection I217-V adapter instead of a numeric value. When I assigned the value other than 1 to the Intel adapter it worked like a charm. It now detects the connection to the Intel adapter as a number 2 and thus invalid.
QUESTION: Is there a way to assign anything other than the PIA adapter a value other than 1 in the Substitute line so the script would work on anyone's computer? If so I will post it.
Darv wrote: ↑November 17th, 2020, 12:09 am
QUESTION: Is there a way to assign anything other than the PIA adapter a value other than 1 in the Substitute line so the script would work on anyone's computer? If so I will post it.
Use IfMatch and the string value of the network description measure rather than substituting the text with numbers .
The IfMatch uses RegExp to set the options directly:
when [MeasureNetwork] equals "Private Internet Access Network Adapter" the match actions are taken
when [MeasureNetwork] equals any other text, the not match actions.