It is currently April 20th, 2024, 5:59 am

Multiple Network Devices

Get help with creating, editing & fixing problems with skins
Ghaster
Posts: 3
Joined: August 15th, 2014, 6:13 pm

Multiple Network Devices

Post by Ghaster »

Hi there,

I´ve got a newbie question:
I try to show the actual IP address of my Notebook.
One for my wired LAN adapter, and one for my WLAN.

Code: Select all

[GetLANIP]
Measure=Plugin
Plugin=Plugins\SysInfo.dll
SysInfoType=IP_ADDRESS
SysInfoData=0
Substitute=".":" . "
UpdateDivider=3

[GetWLANIP]
Measure=Plugin
Plugin=Plugins\SysInfo.dll
SysInfoType=IP_ADDRESS
SysInfoData=4
Substitute=".":" . "
UpdateDivider=3
The problem is, that my Notebook has 4 different network devices.
The SysInfoData for my LAN is 0, for the WLAN it is 4.
(But only, when the LAN-Port is connected)
If I remove the LAN cable, the SysInfoData for my WLAN is 3.

Do you have any ideas, how I can handle this ...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5398
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Multiple Network Devices

Post by eclectic-tech »

Can't test here, but something like this should work...

Code: Select all

[GetLANIP]
Measure=Plugin
Plugin=Plugins\SysInfo.dll
SysInfoType=IP_ADDRESS
SysInfoData=0
Substitute=".":" . "
UpdateDivider=3

[CheckLANConnect]
Measure=Plugin
Plugin=Plugins\SysInfo.dll
SysInfoType=LAN_CONNECTIVITY
SysInfoData=0
IfCondition=CheckLANConnect=1
IfTrueAction=!SetOption GetWLANIP SysInfoData 4
IfFalseAction=!SetOption GetWLANIP SysInfoData 3
IfConditionMode=1
UpdateDivider=3
; Returns 1 if your computer is connected to a LAN, -1 if not. Note: This option value is only available on Windows Vista or later. On Windows XP, it will always return 1.

[GetWLANIP]
Measure=Plugin
Plugin=Plugins\SysInfo.dll
SysInfoType=IP_ADDRESS
SysInfoData=4
Substitute=".":" . "
UpdateDivider=3
Ghaster
Posts: 3
Joined: August 15th, 2014, 6:13 pm

Re: Multiple Network Devices

Post by Ghaster »

Thank you. That is a nice idea.
But ...

When I disconnect my LAN-Adapter, the next SysInfoData=0 Adapter ist a virtual one. And this one is always connected. So, CheckLANConnect will always be 1.

It woud be nice, if I could address the Adapter by name, like "NetworkConnection 1" or "Ethernet". But I didn´t find a solution for that.

I also try to use a variable for SysInfoData=#AdapterID#.
So I set the variable AdapterID=4 in the Variables-Section.
Next I would like to check first, if the IP of this Adapter is 127.0.0.1 or nothing.
If the IP is wrong, I like to change the variable #AdapterID# to 3.
But I don´t understand, how I check the result value against my 127.0.0.1 and how I can change the value of the variable #AdapterID# during runtime.

I hope for an idea ...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5398
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Multiple Network Devices

Post by eclectic-tech »

Ghaster wrote:Thank you. That is a nice idea.
But ...

When I disconnect my LAN-Adapter, the next SysInfoData=0 Adapter ist a virtual one. And this one is always connected. So, CheckLANConnect will always be 1.

It woud be nice, if I could address the Adapter by name, like "NetworkConnection 1" or "Ethernet". But I didn´t find a solution for that.

I also try to use a variable for SysInfoData=#AdapterID#.
So I set the variable AdapterID=4 in the Variables-Section.
Next I would like to check first, if the IP of this Adapter is 127.0.0.1 or nothing.
If the IP is wrong, I like to change the variable #AdapterID# to 3.
But I don´t understand, how I check the result value against my 127.0.0.1 and how I can change the value of the variable #AdapterID# during runtime.

I hope for an idea ...
Been away... :)
You should be able to do this using the SysInfo plugin ADAPTER_DESCRIPTION option and a IfMatch measure to change the #AdapterID#...

Code: Select all

[MeasureDESC]
Measure=Plugin
Plugin=SysInfo
SysInfoType=ADAPTER_DESCRIPTION
SysInfoData=#AdapterID#
IfMatch={Your_ADAPTER_DESCRIPTION}
IfMatchAction=[!SetVariable AdapterID "4"]
IfNotMatchAction=[!SetVariable AdapterID "3"]
IfMatchMode=1
DynamicVariables=1

Replace {Your_ADAPTER_DESCRIPTION} with the exact value returned by the measure when connected.

The PING plugin may work for you to check the address and take an action based on an 'IfMatch' test.

Can't test, but hopefully this gives you some ideas...
Ghaster
Posts: 3
Joined: August 15th, 2014, 6:13 pm

Re: Multiple Network Devices

Post by Ghaster »

YES!

"IfMatch" was the solution. Sometimes it´s so easy, if you know how.
It works very well now.

Thank´s for your help. :welcome:
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5398
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Multiple Network Devices

Post by eclectic-tech »

:thumbup: Great! ... I'm always ready to exercise my grey matter (god knows it needs it!) :? :lol: