It is currently March 29th, 2024, 8:38 am

How to hide text or skin until internet connection is established?

Get help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to hide text or skin until internet connection is established?

Post by balala »

Yincognito wrote: November 3rd, 2019, 8:47 pm Completely agree with balala here - properly delimiting your string helps both you and Rainmeter, and prevents things being interpreted incorrectly on occasion.
Over time this can create a "correct" habit. Related to the quotes for instance, it is extremely recommended to always use them, even if you set some simple numeric values through a (for instance !SetVariable) bang, to get the habit of using them. This way you'll never forget to use them and sometimes this can seem useless, however other times it is absolutely needed. If you have the habit to use them, it's a safety.
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to hide text or skin until internet connection is established?

Post by Yincognito »

Exactly. One thing I hate a lot when writing code is to expect some things to happen a certain way and then spend an hour before realizing that the reason why it didn't work was just a matter of a missed quote/paranthese/comma/whatever. Those small details that are often ignored are the most annoying ones.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
makeitrain
Posts: 11
Joined: October 24th, 2019, 1:10 am

Re: How to hide text or skin until internet connection is established?

Post by makeitrain »

Your attention toward careful coding is insightful and helpful. My discipline is getting stronger each time I ask for advice from such masters as yourselves yet there is much to learn.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to hide text or skin until internet connection is established?

Post by balala »

makeitrain wrote: November 4th, 2019, 12:55 pm yet there is much to learn.
Exactly. Rainmeter can surprise me many times even now after many years of coding and I think I can say many successes I passed through with this wonderful piece of software. Going ahead...
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to hide text or skin until internet connection is established?

Post by Yincognito »

jsmorley wrote: October 28th, 2019, 4:22 pmOr something like this:
....
The WebParser measure will be brought to life and forced to update the first time internet connectivity is "true", then normally once an hour after that.
I finally took the time an tested the code in my weather skin (without the enable part) and it works very well. One little question though: won't the Webparser measure be commanded to continuously update once every second even after it was first instructed to do so, or is the default ForceReload=0 supposed to protect against overpolling the site after the change in internet connection from 0 to 1 was first detected? If the answer to the question is yes (or there's a danger of doing so if not careful), wouldn't be preferrable to store the status of the internet connectivity in a variable and only command the Webparser update if the said variable changed its value (e.g. from 0 to 1, but not if it's still 1 as before)?

EDIT: Sorry, my bad - I forgot the fact that 'IfTrueAction is executed only once when the condition becomes "true", so it needs to become "false" and again "true" to execute again'. I think that makes things safe and clear - I was too used to setting IfConditionMode=1 in most of my IfConditions to remember that the default settings were a good enough protection against overtesting the condition when not necessary.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to hide text or skin until internet connection is established?

Post by Yincognito »

Ok, I implemented jsmorley's code into my feeds skin as well - it was MUCH easier than I suspected it would. It looks like this:

Code: Select all

[MeasureInternet]
Measure=Plugin
Plugin=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
IfCondition=(MeasureInternet=1)
IfTrueAction=[!UpdateMeasure "MS_WebParser_ResetIndexes"][!UpdateMeasureGroup "FeedDerivativeGroup"]
What it does is reset the indexes I use in the skin and update two other measures (i.e. the ones in the FeedDerivativeGroup, that in turn trigger the update of the actual WebParser measure). Now what I noticed is that the process of retrieving the feeds takes place twice (and not once, as one would expect). I'm pretty sure it's not because my skin or my implementation are faulty, but because when connecting to the internet (I'm on a WiFi router), the value of MeasureInternet quickly alternates between (in order) -1 initially,1,-1 and then again 1. It's like I'm connecting twice to the internet in one actual connection, with the first of those two "virtual connections" being followed by a disconnect as well.

I've watched this in the Rainmeter log, so that's how I know it's true and it's not a problem in my skin. You can test it as well and if lucky you'll notice the same behavior. Unfortunately, the -1 to 1, to -1 and then finally to 1 alternation happens very quickly, so I was unable to properly capture it in an .avi/.gif to present it here as "proof". What's up with it? Is it a Windows thing or else, and can it be corrected?

P.S. Could this behavior be related to the fact that I use an internet security suite (AV+firewall) maybe? Just a thought...
EDIT: Apparently, setting something like an UpdateDivider=5 (based on a general Update=1000 in Rainmeter) on the measure is a workaround for this double condition triggering, since the measure won't be able detect the very quick -1 to 1 back and forth in internet connectivity anymore. I would however still be interested in finding out the reason why this happened in the first place (or at least if someone else can replicate the "issue" of the very quick -1 to 1 toggling in the log).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth