LooseAllTheMonies wrote: ↑August 2nd, 2021, 4:28 amI have another issue, if anyone is still checking this thread and would like to help even more again greatly appreciate any and all help. [...]
0. Death.crafter is right with his 2nd question, make sure you clarify exactly the logic that he is referring to, and what you actually want to do.
1. Something along these lines should work (it works for me, except all my NameServer values are blank so I had to use the DhcpSubnetMask value for testing):
Code: Select all
[Variables]
NIC_ID=0016
VPNNameServer=255.0.0.0
...
...
...
[MeasureVPNNameServerVar]
Measure=String
String=#VPNNameServer#
UpdateDivider=-1
[MeasureInterfaceGUID]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\#NIC_ID#
RegValue=NetCfgInstanceId
UpdateDivider=-1
DynamicVariables=1
[MeasureVPNNameServer]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\[MeasureInterfaceGUID]
RegValue=NameServer
UpdateDivider=-1
IfMatch=^[MeasureVPNNameServerVar:EscapeRegExp]$
IfMatchAction=[!SetVariable MatchResult "Match"]
IfNotMatchAction=[!SetVariable MatchResult "Not Match"]
IfMatchMode=1
DynamicVariables=1
...
...
...
2. No need to "use a regexp to make sure it's an IP address and then compare it against the IP in the variable", just directly compare it against the variable, since that is also an IP I suppose, and it's actually your goal. The extra step is pointless, if I understood what you wanted properly.
3. Yes, the
^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$ is correct if we talk about the IPv4 addresses (different for IPv6 ones; I use a similar
^[^\.]+\.[^\.]+\.[^\.]+\.[^\.]+$ for IPv4 and
^[^:]+:[^:]+:[^:]+:[^:]+:[^:]+:[^:]+:[^:]+:[^:]+$ for IPv6), notice the
^ and
$ anchors for the start and end of the string. Brackets are unnecessary in an IfMatch as nothing is being captured and no indexes are being created there, plus, you wouldn't need to use
(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|[MeasureVPNNameServerVar:EscapeRegExp]), notice the (?:) non-capturing group for OR conditionals and the
:EscapeRegExp measure section variable's parameter, for the reason I stated above, not to mention that if you look closely this logical construct will match any IP, not just the VPNServer one.
4. The code above only polls the registry once, at skin refresh, due to the
UpdateDivider=-1 option in the relevant measures. Because of that, this is suited for "on demand" execution and not periodic one. If you want a rare periodic one, just set the
update divider to an integer (let's call it N) greater than 1, because doing so will only update the measures once every N times the value of the skin's (
[Rainmeter] section's)
Update option, in other words if you have
Update=1000 in
[Rainmeter] and
UpdateDivider=3 in your measure, that measure is going to update once every 3 seconds. Yes, it's possible to "execute something" (some bangs, I guess?) when a measure value changed, by using the
OnChangeAction option. There are a couple of catches with that though: it won't react the first time, as you can see in the manual, and would make using other more flexible ...Action options in the measure trickier, especially when trying to do them all "at the same time". Basically, what you choose depends on your scenario.