Jump to content

Get Ip with @Ipaddress of specific networkcard


Recommended Posts

Hi,
I'm trying to make an application where I can read and set the ip address of a specifique network card named PC.
How can I achieve this. I already found out that I need to take @IPaddress4 macro to read the right ip address but I would like to verify this by comparing with the nw-card name (being PC).

This is my code for so far...:

 

; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ;
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiButton.au3>
#Include <GuiIPAddress.au3>


$IP_PC = GUICreate("IP PC",388,419,-1,-1,-1,-1)
GUICtrlCreateButton("SET IP to non-GMP Network",20,170,315,135,$BS_COMMANDLINK,-1)
DllCall("user32.dll", "UINT", "SendMessage", "handle", GUICtrlGetHandle(-1), "UINT", $BCM_SETNOTE, "ptr*", 0, "wstr", "Changes IP address of PC compliant to NON-GMP-Network")
DllCall("user32.dll", "UINT", "SendMessage", "handle", GUICtrlGetHandle(-1), "UINT", $BCM_SETSHIELD, "ptr*", 0, "BOOL",false)
GUICtrlCreateLabel("Current IP:",20,340,119,31,-1,-1)
GUICtrlSetFont(-1,16,400,0,"MS Sans Serif")
GUICtrlSetColor(-1,"0x000080")
GUICtrlSetBkColor(-1,"-2")
$ip7 = _GUICtrlIpAddress_Create($IP_PC,148,340,217,31,-1,$WS_EX_CLIENTEDGE)
_GUICtrlIpAddress_Set($ip7,@IPAddress3)
GUICtrlSetFont(-1,16,400,0,"MS Sans Serif")
GUICtrlSetColor(-1,"0x000080")
GUICtrlSetBkColor(-1,"-2")
GUICtrlCreateButton("SET IP to GMP Network",20,20,311,135,$BS_COMMANDLINK,-1)
DllCall("user32.dll", "UINT", "SendMessage", "handle", GUICtrlGetHandle(-1), "UINT", $BCM_SETNOTE, "ptr*", 0, "wstr", "Changes IP address of PC compliant to GMP-Network")
DllCall("user32.dll", "UINT", "SendMessage", "handle", GUICtrlGetHandle(-1), "UINT", $BCM_SETSHIELD, "ptr*", 0, "BOOL",false)
GUISetState(@SW_SHOW,$IP_PC)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Link to comment
Share on other sites

Not sure if this is being written for just one computer so that you do not have to worry much about adapter order.

But if I needed an IP for a specific adapter I think I would just go the route of ipconfig /all and parse the results with regex

An example, if I wanted VMWare VNet1 from my list of Adapters, change as needed for your search.

Get the data using Run(@Comspec ... @STDOUT..)

https://regex101.com/r/SEJadi/1

 

Edited by ViciousXUSMC
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...