Display Network Adapters In ComboBox Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
edc
Posts: 26
Joined: 17 Jun 2021, 16:23

Display Network Adapters In ComboBox

Post by edc » 03 Dec 2022, 20:49

Hello,
I'm trying to get my Network Adapters into a ComboBox. Currently I have it saving the data to my Clipboard and display the Clipboard in the ComboBox, but it is all on 1 line. How do I remove the extra spaces and returns from the clipboard and have each entry on a new line clean?

Data Set, which needs spaces and returns removed:
NetConnectionID



NIC-1

NIC-2





















NIC-3

NIC-4

NetConnectionID.png
NetConnectionID.png (13.98 KiB) Viewed 271 times

Code: Select all

RunWait, %ComSpec% /c wmic nic get netconnectionID|clip,,hide

Gui, Add, ComboBox, w300 vddl, %Clipboard%||
Gui, Add, Button, Default, OK
Gui, Show
Return

ButtonOK:
Gui, Submit
MsgBox, %ddl%

guiclose:
ExitApp

end::
	exitapp
return
ComboBox.png
ComboBox.png (4.31 KiB) Viewed 271 times
MsgBox.png
MsgBox.png (6.4 KiB) Viewed 271 times

User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: Display Network Adapters In ComboBox

Post by mikeyww » 03 Dec 2022, 21:32

Code: Select all

Clipboard =
RunWait, %ComSpec% /c wmic nic get netconnectionID | clip,, Hide
ClipWait, 0
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
 Return
} Else list := Trim(RegExReplace(StrReplace(Clipboard, "NetConnectionID"), "\h*\R\s*", "|"), "|")
Gui, Font, s10
Gui, Add, DropDownList, w240 vsel   , %list%
Gui, Add, Button      , wp   Default, OK
Gui, Show,, NIC
Return

ButtonOK:
Gui, Submit
MsgBox, %sel%

GuiClose:
ExitApp

edc
Posts: 26
Joined: 17 Jun 2021, 16:23

Re: Display Network Adapters In ComboBox

Post by edc » 03 Dec 2022, 21:56

Hello,
Thanks for the fast response that works great!

Is it possible to make the first entry display as the default value before making a selection?

Thanks.

User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: Display Network Adapters In ComboBox  Topic is solved

Post by mikeyww » 03 Dec 2022, 21:57

Code: Select all

Clipboard =
RunWait, %ComSpec% /c wmic nic get netconnectionID | clip,, Hide
ClipWait, 0
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
 Return
} Else list := Trim(RegExReplace(StrReplace(Clipboard, "NetConnectionID"), "\h*\R\s*", "|"), "|")
Gui, Font, s10
Gui, Add, DropDownList, w240 Choose1 vsel, %list%
Gui, Add, Button      , wp   Default     , OK
Gui, Show,, NIC
Return

ButtonOK:
Gui, Submit
MsgBox, %sel%

GuiClose:
ExitApp

edc
Posts: 26
Joined: 17 Jun 2021, 16:23

Re: Display Network Adapters In ComboBox

Post by edc » 03 Dec 2022, 22:04

Thanks this is working well.

Post Reply

Return to “Ask for Help (v1)”