It is currently April 27th, 2024, 8:14 pm

Show all active IPv4 regardless of adapter name / index

Get help with creating, editing & fixing problems with skins
AmbientMike
Posts: 25
Joined: October 18th, 2016, 2:26 pm

Show all active IPv4 regardless of adapter name / index

Post by AmbientMike »

Hi all,

Having a bit of a problem getting my head around this one. I'm having to revisit a skin I made some time ago and have noted a change in the way that the SysInfo Measure works which is now giving me some grief.

Ideally what I want to happen is that all active IP v4 addresses are shown (or maximum 4 or 5) which would be fine if this was for one specific device but the skin is deployed to a large number of devices with varying configurations. So, regardless of hardware and interface indexes, I need to show the IPv4 addresses. Previously I'd been just trying all indexes from 0-9 and hiding them if they're not present. I noted the other day that VPN addresses were not showing or we were getting duplicated entries. I note that this is because using "SysInfoData=0 for IP_ADDRESS now translates to "Best" and that my active VPN network index was 24 so was being ignored by the measures.

So... How can I get Rainmeter to effectively loop through active network adapters and display IPv4 information without knowing the names of the installed adapters or the index numbers?

An example of the current setup is...

Code: Select all

[MeasureIP0]
Measure=SysInfo
SysInfoType=IP_ADDRESS
SysInfoData=0
IfMatch=^$|^127\.0\.0\.1$|^169\.(.*)$
IfMatchAction=[!HideMeter "MeterResult01"]
IfNotMatchAction=[!ShowMeter "MeterResult01"]

[MeasureIP1]
Measure=SysInfo
SysInfoType=IP_ADDRESS
SysInfoData=1
IfMatch=^$|^127\.0\.0\.1$|^169\.(.*)$
IfMatchAction=[!HideMeter "MeterResult11"]
IfNotMatchAction=[!ShowMeter "MeterResult11"]

[MeterResult01]
Meter=STRING
MeasureName=MeasureIP0
X=#CURRENTCONFIGWIDTH#
Y=0r
W=#CURRENTCONFIGWIDTH#
StringAlign=Right
Padding=10,5,15,0
FontSize=12
FontColor=255,255,255,255
StringStyle=Bold
AntiAlias=1
Text=%1

[MeterResult11]
Meter=STRING
MeasureName=MeasureIP1
X=#CURRENTCONFIGWIDTH#
Y=0r
W=#CURRENTCONFIGWIDTH#
StringAlign=Right
Padding=10,0,15,0
FontSize=12
FontColor=255,255,255,255
StringStyle=Bold
AntiAlias=1
Text=%1
Thanks in advance...
User avatar
SilverAzide
Rainmeter Sage
Posts: 2613
Joined: March 23rd, 2015, 5:26 pm

Re: Show all active IPv4 regardless of adapter name / index

Post by SilverAzide »

AmbientMike wrote: March 21st, 2024, 10:52 am Hi all,

Having a bit of a problem getting my head around this one. I'm having to revisit a skin I made some time ago and have noted a change in the way that the SysInfo Measure works which is now giving me some grief.

Ideally what I want to happen is that all active IP v4 addresses are shown (or maximum 4 or 5) which would be fine if this was for one specific device but the skin is deployed to a large number of devices with varying configurations. So, regardless of hardware and interface indexes, I need to show the IPv4 addresses. Previously I'd been just trying all indexes from 0-9 and hiding them if they're not present. I noted the other day that VPN addresses were not showing or we were getting duplicated entries. I note that this is because using "SysInfoData=0 for IP_ADDRESS now translates to "Best" and that my active VPN network index was 24 so was being ignored by the measures.

So... How can I get Rainmeter to effectively loop through active network adapters and display IPv4 information without knowing the names of the installed adapters or the index numbers?

Thanks in advance...
That scheme can't ever really work. There are dozens and dozens of adapters in a normal Windows machine, and the index numbers change all the time, so just checking indexes 0-9 can't work unless you are really lucky. My machines typically have 50+ adapters, and the active adapter index is usually something >20, for example.

Secondly, your question "How can I get Rainmeter to effectively loop through active network adapters..." contains a key point. Rainmeter doesn't "loop". You need to either build 50+ measures to try every possible adapter on your system (however many you have), or come up with a better approach.

I'd suggest something like this. First, use a RunCommand measure to fire off a PowerShell command that can fetch all the IPv4 addresses on the machine. Second, Use a WebParser measure (with a regex that uses lookaheads to handle multiple results) to read this resulting PowerShell output to parse out all the IP address data (for an many rows as you want/need).

This way, you don't need to know adapter names or indexes, and you won't need dozens and dozens of measures pinging useless virtual adapters.

To get you started, here is a PS command that will get you all the IPv4 addresses on your machine. You only really need the first column, but I added the others so you can see the indexes and adapter names in case you are curious.

Code: Select all

Get-NetIPAddress | Where-Object { $_.AddressFamily -eq 'IPv4' } | Where-Object { $_.IPAddress -ne '127.0.0.1' } | Sort-Object -Property InterfaceIndex | Format-Table -Property IPAddress, InterfaceIndex, InterfaceAlias
Gadgets Wiki GitHub More Gadgets...
AmbientMike
Posts: 25
Joined: October 18th, 2016, 2:26 pm

Re: Show all active IPv4 regardless of adapter name / index

Post by AmbientMike »

Thanks for that. The thing is it the old SysInfo dll plugin did work exactly as I wanted and SysInfo Data 0-9 would give you (up to 9 of) the active IPv4 addresses and since it's been merged the different behaviour, to me, is a real limitation. I will probably roll-back until I can script something that replicates the old functionality.