It is currently April 26th, 2024, 2:59 am

Network interface IP adresses

Get help with creating, editing & fixing problems with skins
TheDuke
Posts: 2
Joined: September 2nd, 2020, 6:37 pm

Network interface IP adresses

Post by TheDuke »

I've been scouring the web for a finished style that would fit my desires.

Looking to show my wan IP, ethernet IP and Wifi IP
I do have other interfaces but they are not relevant in my situation.

I found https://forum.rainmeter.net/viewtopic.php?t=27988#p145400 that helped me on my way.
It seems that I can automatically get my wan and "Best" active network adapters IP, but how can I chose wich IP i select and show?

Thanks for a nice forum!
User avatar
SilverAzide
Rainmeter Sage
Posts: 2610
Joined: March 23rd, 2015, 5:26 pm

Re: Network interface IP adresses

Post by SilverAzide »

Do you have both your Ethernet and WiFi adapters active at the same time? Unless you are bridging connections or doing something special, normally Windows will pick one or the other, but not both. You can find out by opening a command prompt and entering ipconfig /all and you'll see your adapters and the IP address of each. If your machine is switching between adapters (i.e., only one active at a time), your best bet is to use "Best".
(Heh heh, see what I did there? ;))

If you really do have multiple active adapters, then you can simply use two measures to find the internal IPs, plus another for your external IP:

Code: Select all

[MeasureIPEthernet]
Measure=Plugin
Plugin=SysInfo
SysInfoType=IP_ADDRESS
SysInfoData=<name of your ethernet adapter>

[MeasureIPWifi]
Measure=Plugin
Plugin=SysInfo
SysInfoType=IP_ADDRESS
SysInfoData=<name of your wifi adapter>

[MeasureIPExternal]
Measure=WebParser
URL=https://ipv4.icanhazip.com
RegExp=(?siU)^(.*)$
StringIndex=1
The name of your adapter is shown by the above ipconfig command, as "Description".
Gadgets Wiki GitHub More Gadgets...
TheDuke
Posts: 2
Joined: September 2nd, 2020, 6:37 pm

Re: Network interface IP adresses

Post by TheDuke »

Thank you for your help!

I did see what you did :jawdrop

And i learned how measures "work" that they are another place in the config.
I figured that the up and download speeds are still from "best" adapter and so shows where im connected to the internet?
This is a help when i at work are connected to 2 networks for setting up equipment.

Is there a way so tha ti can click the IP and have windows open up settings for that adapter for easy setting new IP?

With some code from this post i got this output
https://forum.rainmeter.net/viewtopic.php?t=31511#p159464

Code: Select all

Interface Name                                                                   Alias                         Virtual
--------------                                                                   -----                         -------
Intel(R) Ethernet Connection (6) I219-V                                          Ethernet                        False
Bluetooth Device (Personal Area Network)                                         Bluetooth-netværksforbindelse    True
Cisco AnyConnect Secure Mobility Client Virtual Miniport Adapter for Windows x64 Ethernet 2                       True
TeamViewer VPN Adapter                                                           Ethernet 3                       True
VirtualBox TAP Adapter                                                           LinkManager Adapter              True
Intel(R) Wireless-AC 9560 160MHz                                                 Wi-Fi                           False
And my entire config looking like this

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=Network
Author=poiru
Information=Shows your IP address and network activity.
License=Creative Commons BY-NC-SA 3.0
Version=1.0.0

[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
maxDownload=10485760
MaxUpload=10485760
; Set maxDownload and maxUpload to your maximum download and upload speed in bits.
; To convert kilobits, megabits, kilobytes, and megabytes into bits, go to www.google.com
; and search for something like "10 megabytes in bits".

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

[MeasureIPLan]
Measure=Plugin
Plugin=SysInfo
SysInfoData=Best
SysInfoType=IP_ADDRESS

[MeasureIP]
; This measure returns your IP. WebParser measures are relatively complicated. If you're a beginner with
; Rainmeter, take a look at some of the other illustro skins before modifying this one.
Measure=WebParser
URL=http://icanhazip.com/
RegExp=(?siU)^(.*)$
StringIndex=1
Substitute="":"N/A"
; Substitute works as follows: "A":"B" where A is a string to substitute and B is a string
; to substitute with. In this case, it substutes "" (i.e. empty) to N/A

[measureNetIn]
Measure=NetIn
NetInSpeed=#maxDownload#
; NetInSpeed must be set so your maximun download speed for the download bar to scale correctly

[measureNetOut]
Measure=NetOut
NetOutSpeed=#maxUpload#

; Tips from https://forum.rainmeter.net/viewtopic.php?f=5&t=35970&e=1&view=unread#unread
; https://forum.rainmeter.net/viewtopic.php?t=31511#p159443
; Powershell code: get-wmiobject win32_networkadapter | select netconnectionid, name, InterfaceIndex, netconnectionstatus
[MeasureIPEthernet]
Measure=Plugin
Plugin=SysInfo
SysInfoType=IP_ADDRESS
SysInfoData="Intel(R) Ethernet Connection (6) I219-V"

[MeasureIPWifi]
Measure=Plugin
Plugin=SysInfo
SysInfoType=IP_ADDRESS
SysInfoData="Intel(R) Wireless-AC 9560 160MHz"

; ----------------------------------
; 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

[styleSeperator]
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=Network
; Even though the text is set to Network, Rainmeter will display
; it as NETWORK, because styleTitle contains StringCase=Upper.

[meterIPLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=40
W=190
H=14
Text=IP Web Address

[meterIPValue]
Meter=String
MeterStyle=styleRightText
MeasureName=measureIP
X=200
Y=0r
; r stands for relative. In this case, the Y postition of meterValueCPU is 0 pixels
; below the Y value of the previous meter (i.e it's the same as in meterLabelCPU).
W=190
H=14
Text=%1
; %1 stands for the value of MeasureName (measureIP in this case).

[meterSeperator1]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=12r
W=190
H=1

[meterIPLanLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=60
W=190
H=14
Text=IP Lan Address

[meterIPLanValue]
Meter=String
MeterStyle=styleRightText
MeasureName=MeasureIPEthernet
X=200
Y=0r
; r stands for relative. In this case, the Y postition of meterValueCPU is 0 pixels
; below the Y value of the previous meter (i.e it's the same as in meterLabelCPU).
W=190
H=14
Text=%1
; %1 stands for the value of MeasureName (measureIP in this case).

[meterSeperator2]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=12r
W=190
H=1

[meterIPWiFiLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=80
W=190
H=14
Text=IP WiFi Address

[meterIPWifiValue]
Meter=String
MeterStyle=styleRightText
MeasureName=MeasureIPWifi
X=200
Y=0r
; r stands for relative. In this case, the Y postition of meterValueCPU is 0 pixels
; below the Y value of the previous meter (i.e it's the same as in meterLabelCPU).
W=190
H=14
Text=%1
; %1 stands for the value of MeasureName (measureIP in this case).

[meterSeperator3]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=12r
W=190
H=1

[meterUploadLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=100
W=190
H=14
Text=Upload

[meterUploadValue]
Meter=String
MeterStyle=styleRightText
MeasureName=measureNetOut
X=200
Y=0r
W=190
H=14
Text=%1B/s
NumOfDecimals=1
AutoScale=1
; Because measureIP returns the current upload speed in bytes, we must use AutoScale=1 to
; automatically scale the value into a more readable figure.

[meterUploadBar]
Meter=Bar
MeterStyle=styleBar
MeasureName=measureNetOut
X=10
Y=12r
W=190
H=1

[meterDownloadLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=120
W=190
H=14
Text=Download

[meterDownloadValue]
Meter=String
MeterStyle=styleRightText
MeasureName=measureNetIn
X=200
Y=0r
W=190
H=14
Text=%1B/s
NumOfDecimals=1
AutoScale=1

[meterDownloadBar]
Meter=Bar
MeterStyle=styleBar
MeasureName=measureNetIn
X=10
Y=12r
W=190
H=1
Produces following style

Image
SilverAzide wrote: September 2nd, 2020, 9:17 pm Do you have both your Ethernet and WiFi adapters active at the same time? Unless you are bridging connections or doing something special, normally Windows will pick one or the other, but not both. You can find out by opening a command prompt and entering ipconfig /all and you'll see your adapters and the IP address of each. If your machine is switching between adapters (i.e., only one active at a time), your best bet is to use "Best".
(Heh heh, see what I did there? ;))

If you really do have multiple active adapters, then you can simply use two measures to find the internal IPs, plus another for your external IP:

Code: Select all

[MeasureIPEthernet]
Measure=Plugin
Plugin=SysInfo
SysInfoType=IP_ADDRESS
SysInfoData=<name of your ethernet adapter>

[MeasureIPWifi]
Measure=Plugin
Plugin=SysInfo
SysInfoType=IP_ADDRESS
SysInfoData=<name of your wifi adapter>

[MeasureIPExternal]
Measure=WebParser
URL=https://ipv4.icanhazip.com
RegExp=(?siU)^(.*)$
StringIndex=1
The name of your adapter is shown by the above ipconfig command, as "Description".
User avatar
SilverAzide
Rainmeter Sage
Posts: 2610
Joined: March 23rd, 2015, 5:26 pm

Re: Network interface IP adresses

Post by SilverAzide »

TheDuke wrote: September 3rd, 2020, 5:40 pm I figured that the up and download speeds are still from "best" adapter and so shows where im connected to the internet?
This is a help when i at work are connected to 2 networks for setting up equipment.
Actually, based on that code, your upload/download speeds are probably for ALL adapters, not just the best one. You can fix this to get the speeds for specific adapters like this (for example):

Code: Select all

[measureNetInEthernet]
Measure=NetIn
Interface="Intel(R) Ethernet Connection (6) I219-V"
NetInSpeed=#maxDownload#
; NetInSpeed must be set so your maximun download speed for the download bar to scale correctly

[measureNetOutEthernet]
Measure=NetOut
Interface="Intel(R) Ethernet Connection (6) I219-V"
NetOutSpeed=#maxUpload#

[measureNetInWiFi]
Measure=NetIn
Interface="Intel(R) Wireless-AC 9560 160MHz"
NetInSpeed=#maxDownload#
; NetInSpeed must be set so your maximum download speed for the download bar to scale correctly

[measureNetOutWiFi]
Measure=NetOut
Interface="Intel(R) Wireless-AC 9560 160MHz"
NetOutSpeed=#maxUpload#
You can then add additional meters to display the separate ethernet/wifi values.
TheDuke wrote: September 3rd, 2020, 5:40 pm Is there a way so tha ti can click the IP and have windows open up settings for that adapter for easy setting new IP?
On the meter you want to click on, add the following line:

Code: Select all

LeftMouseUpAction=[Shell:::{7007ACC7-3202-11D1-AAD2-00805FC1270E}]
However, I don't think you can jump right to the exact adapter, but that's how you'd add an action that would do it. Another way I use is to allow double-clicking anywhere on the skin to pop up the dialog. In the [Rainmeter] section, add:

Code: Select all

LeftMouseDoubleClickAction=[Shell:::{7007ACC7-3202-11D1-AAD2-00805FC1270E}]
There are several network shortcuts you can use. All are listed here: https://docs.rainmeter.net/tips/launching-windows-special-folders/
Gadgets Wiki GitHub More Gadgets...