Jump to content

Get NetConnection status


Syed23
 Share

Recommended Posts

Hi All,

To improve my knowledge i have written another basic example script. please help me and give me some suggestion on this to improve more..... The below script will check the connection status of the net..

Here is the UDF.

#include-once
Local $strcomputer,$objWMIService,$colItems ,$objItem
 
Func Connection($strcomputer)
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
 
 $colItems = $objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapter")
 
For $objItem in $colItems
    Select
Case $objItem.NetConnectionStatus
        Case 0
$strStatus = "Disconnected"
        Case 1
$strStatus = "Connecting"
        Case 2
$strStatus = "Connected"
        Case 3
$strStatus = "Disconnecting"
        Case 4
$strStatus = "Hardware not present"
        Case 5
$strStatus = "Hardware disabled"
        Case 6
$strStatus = "Hardware malfunction"
        Case 7
$strStatus = "Media disconnected"
        Case 8
$strStatus = "Authenticating"
        Case 9
$strStatus = "Authentication succeeded"
        Case 10
$strStatus = "Authentication failed"
        Case 11
$strStatus = "Invalid address"
        Case 12
$strStatus = "Credentials required"
    EndSelect
 Next
Return $strStatus
EndFunc

Here is the example:

#include <Net.au3>
MsgBox(0,"",Connection(@ComputerName))

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

This line:

Local $strcomputer,$objWMIService,$colItems ,$objItem

should be inside the function. Otherwise it will declare those variables as global and may cause interaction with other parts of a script if you reuse the variable names. Declaring a variable as Local in a Global scope declares them as global automatically, the Local designation is ignored in this case.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I also noticed that the value in $strstatus is only going to hold the last value of $colitems because you don't preserve any other readings. My computer shows several network connections, most disconnected, that were added because of VPN connections and other wireless locations I've connected it to.

Something like this might be more in line with what you're looking to show.

Func Connection($strcomputer)
    Local $strStatus=""
    $objWMIService = ObjGet("winmgmts:\\" & $strcomputer & "\root\cimv2")

    $colItems = $objWMIService.ExecQuery _
            ("Select * from Win32_NetworkAdapter")

    For $objItem In $colItems
        Switch $objItem.NetConnectionStatus
            Case 0
                $strStatus &= "Disconnected" & @LF
            Case 1
                $strStatus &= "Connecting" & @LF
            Case 2
                $strStatus &= "Connected" & @LF
            Case 3
                $strStatus &= "Disconnecting" & @LF
            Case 4
                $strStatus &= "Hardware not present" & @LF
            Case 5
                $strStatus &= "Hardware disabled" & @LF
            Case 6
                $strStatus &= "Hardware malfunction" & @LF
            Case 7
                $strStatus &= "Media disconnected" & @LF
            Case 8
                $strStatus &= "Authenticating" & @LF
            Case 9
                $strStatus &= "Authentication succeeded" & @LF
            Case 10
                $strStatus &= "Authentication failed" & @LF
            Case 11
                $strStatus &= "Invalid address" & @LF
            Case 12
                $strStatus &= "Credentials required" & @LF
        EndSwitch
    Next
    Return $strStatus
EndFunc   ;==>Connection
Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Thanks for all your response! I am glad to get suggestion and i have modified my scripts!

BrewManNH,

why i am getting result like attached screen shot? i am expecting the result should be either "Connected"or "disconnected" or "Hardware not found".But the result shows 7 times as disconnected and 1 time connected.

Edited:

i got it why it happened i moddifed the script again. But still i have a question. My machine is connected with network, but still shows as disconnected? i am wondering why :graduated:

Edited by Syed23

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

is this correct am i doing?

Global $strcomputer, $objWMIService, $colItems, $objItem
 
Connection(@ComputerName)
 
 
Func Connection($strcomputer)
Local $strStatus = ""
$objWMIService = ObjGet("winmgmts:\\" & $strcomputer & "\root\cimv2")
 
$colItems = $objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapter where NetConnectionStatus='2'")
$strStatus = "Disconnected"
For $objItem In $colItems
Switch $objItem.NetConnectionStatus
Case 0
$strStatus = "Disconnected"
Case 1
$strStatus = "Connecting"
Case 2
$strStatus = "Connected"
Case 3
$strStatus = "Disconnecting"
Case 4
$strStatus = "Hardware not present"
Case 5
$strStatus = "Hardware disabled"
Case 6
$strStatus = "Hardware malfunction"
Case 7
$strStatus = "Media disconnected"
Case 8
$strStatus = "Authenticating"
Case 9
$strStatus = "Authentication succeeded"
Case 10
$strStatus = "Authentication failed"
Case 11
$strStatus = "Invalid address"
Case 12
$strStatus = "Credentials required"
EndSwitch
 
Next
MsgBox(0,"", $strStatus)
EndFunc   ;==>Connection

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

Hi, maybe in this page you can meet anything. The link is:

http://blogs.technet.com/b/heyscriptingguy/archive/2007/08/20/how-can-i-tell-if-a-wireless-network-adapter-is-connected-to-the-network.aspx

Greetings, Frank Rodriguez.

Link to comment
Share on other sites

Thanks for all your response! I am glad to get suggestion and i have modified my scripts!

BrewManNH,

why i am getting result like attached screen shot? i am expecting the result should be either "Connected"or "disconnected" or "Hardware not found".But the result shows 7 times as disconnected and 1 time connected.

Edited:

i got it why it happened i moddifed the script again. But still i have a question. My machine is connected with network, but still shows as disconnected? i am wondering why :D

You're showing as disconnected because you broke the functionality of the script again by "fixing" the script back to the way you had it before. You should reread what I wrote about the $strstatus value in my post and try and figure out what you're doing wrong, and where you really need to look to see if a specific NIC is connected or not, not whether all the network connections on your system are connected or not.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Yeah! :D now i fixed it completely! Thanks :oops:

So.....

This is an Example Script Forum, try to work out the protocol when you have improved a script.

Or was this a thinly veiled support question?

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

This is an Example Script Forum, try to work out the protocol when you have improved a script.

Actually this brings up a valid question, if you've specified somewhere along the course of the conversation that you've fixed a problem with the initial code example (that you've freely posted without a license,) is it mandatory to update the original post? Or could this be construed as breaking the 'ask for source code' rules?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Here is a better approach >> the huge difference is this gets rid of the connections the average user isn't really concerned about, for example I'm only interested in the physical connections i.e. WLAN, Bluetooth & LAN. It also returns an Array and not a String as well as telling you what the adapters are!

Function:

#include <Array.au3>

Local $aArray = _AdapterConnections() ; Data is returned as a 2D Array. Adapter|Status.
_ArrayDisplay($aArray)

For $i = 1 To $aArray[0][0]
    ConsoleWrite('Adapter: ' & $aArray[$i][0] & ' is currently ' & $aArray[$i][1] & '.' & @LF)
Next

Func _AdapterConnections($sComputer = @ComputerName)
    Local $aReturn[1][2] = [[0, 2]], $iDimension = 0, $sDelimeter = Chr(01), $sReturn = ''
    Local $aStatus[13] = ['Disconnected', 'Connecting', 'Connected', 'Disconnecting', 'Hardware not present', _
            'Hardware disabled', 'Hardware malfunction', 'Media disconnected', 'Authenticating', 'Authentication succeeded', _
            'Authentication failed', 'Invalid address', 'Credentials required']

    Local $oWMIService = ObjGet('winmgmts:' & $sComputer & '')
    Local $oColItems = $oWMIService.ExecQuery('Select * From Win32_NetworkAdapter', 'WQL', 0x30)

    If IsObj($oColItems) Then
        For $oObjItem In $oColItems
            If $oObjItem.AdapterType = '' Or $oObjItem.NetConnectionID = '' Then ; Ensures that the connections are physical adapters.
                ContinueLoop
            EndIf
            If StringInStr($sDelimeter & $sReturn, $sDelimeter & $oObjItem.Description & $sDelimeter, 1) Then ; Ensures there are no duplicates.
                ContinueLoop
            EndIf
            $sReturn &= $oObjItem.Description & $sDelimeter

            If ($aReturn[0][0] + 1) >= $iDimension Then ; http://www.autoitscript.com/forum/topic/129689-redim-the-most-efficient-way-so-far-when-you-have-to-resize-an-existing-array/
                $iDimension = ($aReturn[0][0] + 1) * 2
                ReDim $aReturn[$iDimension][$aReturn[0][1]]
            EndIf

            $aReturn[0][0] += 1
            $aReturn[$aReturn[0][0]][0] = $oObjItem.Description
            For $i = 0 To 12
                If $oObjItem.NetConnectionStatus = $i Then ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx
                    $aReturn[$aReturn[0][0]][1] = $aStatus[$i]
                    ExitLoop
                EndIf
            Next
        Next
    EndIf

    ReDim $aReturn[$aReturn[0][0] + 1][$aReturn[0][1]]
    $aReturn[0][1] = ''
    Return $aReturn
EndFunc   ;==>_AdapterConnections
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

What I meant was, the OP posted here in the Example Forum.

Then grins with glee after "fixing it completely" and disappears into the night, suggesting it was really just support they wanted in the first place, not to provide an example.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

i did not disappear John. Here is a public holiday and so i did not come to office and i did not get a chance to reply. Here is my fixed code. Thanks for the open comment :D

#include-once
Global $strcomputer, $objWMIService, $colItems, $objItem
 
Func Connection($strcomputer)
Local $strStatus = ""
$objWMIService = ObjGet("winmgmts:\\" & $strcomputer & "\root\cimv2")
 
$colItems = $objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapter where NetConnectionStatus='2'")
$strStatus = "Disconnected";    if connection is not there it won't go inside the loop and it will use this value
For $objItem In $colItems
Switch $objItem.NetConnectionStatus
Case 0
$strStatus = "Disconnected"
Case 1
$strStatus = "Connecting"
Case 2
$strStatus = "Connected"
Case 3
$strStatus = "Disconnecting"
Case 4
$strStatus = "Hardware not present"
Case 5
$strStatus = "Hardware disabled"
Case 6
$strStatus = "Hardware malfunction"
Case 7
$strStatus = "Media disconnected"
Case 8
$strStatus = "Authenticating"
Case 9
$strStatus = "Authentication succeeded"
Case 10
$strStatus = "Authentication failed"
Case 11
$strStatus = "Invalid address"
Case 12
$strStatus = "Credentials required"
EndSwitch
 
Next
Return $strStatus
EndFunc   ;==>Connection

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

Syed23,

Your code works, but doesn't meet what I would call a basic standard of coding, here's why >>

1. You're requesting the return of active connections only, thus rendering the Switch...EndSwitch useless.

2. If only returns the last active connection it finds, strange considering I have Bluetooth and WLAN enabled. (See BrewManNH's post as to why.)

3. Using Global declaration in this example isn't required.

How I would do your previous Example:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <Array.au3>
 
Global $aArray
 
$aArray = _AdaptersConnected() ; Data is returned as a 1D Array. Adapter.
_ArrayDisplay($aArray)
 
For $A = 1 To $aArray[0]
    ConsoleWrite("Adapter: " & $aArray[$A] & " is currently Connected." & @LF)
Next
 
Func _AdaptersConnected($sComputer = @ComputerName)
    Local $aReturn[1] = [0], $iDimension = 0, $oColItems, $oWMIService, $sDelimeter = Chr(01), $sReturn = ""
 
    $oWMIService = ObjGet("winmgmts:\\" & $sComputer & "\")
    $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapter Where NetConnectionStatus='2'", "WQL", 0x30)
 
    If IsObj($oColItems) Then
        For $oObjItem In $oColItems
            If $oObjItem.AdapterType = "" Or $oObjItem.NetConnectionID = "" Then ; Ensures that the connections are physical adapters.
                ContinueLoop
            EndIf
            If StringInStr($sDelimeter & $sReturn, $sDelimeter & $oObjItem.Description & $sDelimeter, 1) Then ; Ensures there are no duplicates.
                ContinueLoop
            EndIf
            $sReturn &= $oObjItem.Description & $sDelimeter
 
            If ($aReturn[0] + 1) >= $iDimension Then ; http://www.autoitscript.com/forum/topic/...en-you-have-to-resize-an-exist
                $iDimension = ($aReturn[0] + 1) * 2
                ReDim $aReturn[$iDimension]
            EndIf
 
            $aReturn[0] += 1
            $aReturn[$aReturn[0]] = $oObjItem.Description
        Next
    EndIf
 
    ReDim $aReturn[$aReturn[0] + 1]
    Return $aReturn
EndFunc   ;==>_AdaptersConnected
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

:D hmmm... ok i will use your example and i will compare myself what is the difference. Thanks for your suggestion guinness!

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

Look at the ConsoleWrite() with your version I get 1 connected when I should get 2 and secondly what is connected? Mine shows the adapter names.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I left my example as a way to "teach him to fish", obviously fishing isn't his forte.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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