Jump to content

Recommended Posts

Posted

Hi Guys and Gals,

I am trying to get extract selected text in a combo box.

The code below is just a simple example of what I am trying to get at, I figured if I can get it to display in a message I can then add it to my main code.

Basically what I need is to get the text selected in the Combo Box so I can use it in below scenario:

This is what I have:

RunWait(@ComSpec & " /c " & 'netsh interface ip set address name= "Wireless Network Connection" static '& $IPAddressMessage &' '& $SubNetMessage &' '& $GatwayMessage &' 1' , "", @SW_HIDE)

This is what I want:

RunWait(@ComSpec & " /c " & 'netsh interface ip set address name= "& $Available_Connections & " static '& $IPAddressMessage &' '& $SubNetMessage &' '& $GatwayMessage &' 1' , "", @SW_HIDE)

So depending on what Network Connections are available I can select the one I want to run the netsh command on.

Hope this makes sense and someone can help me cause I am pulling my hair out again.

Please see what I have

Opt ("GUIOnEventMode", 1)

#Include <GuiConstants.au3>

Global $connection

Global $objwmiservice = ObjGet('winmgmts:\\localhost\root\CIMV2')

Local $Main_Form = GUICreate("My test GUI", 300,100,-1,-1)

GUICtrlCreateGroup("Select Network connection", 5, 5, 280, 50)

Local $NIC_Conect = GUICtrlCreateCombo ("Select profile ---", 15,25,150)

Local $Available_Connections = GUICtrlRead($NIC_Conect)

Local $connection = $objWMIService.ExecQuery ('SELECT * FROM Win32_NetworkAdapter', 'WQL', 0x10 + 0x20)

If IsObj($connection) Then

For $wmiServices In $connection

If $wmiServices.netconnectionstatus = 2 Then GUICtrlSetData($NIC_Conect, $wmiServices.netconnectionid)

GUISetState()

Next

EndIf

GUICtrlCreateGroup("", -99, -99, 1, 1)

;Buttons

;========

$testNIC_Read=GUICtrlCreateButton ("Read Selected", 170,24,90,22)

GUICtrlSetOnEvent($testNIC_Read,"_testConnection")

$Exit = GUICtrlCreateButton ("Exit Test",100,60,80,30)

GUICtrlSetOnEvent($Exit,"_Exit")

;Functions

;=========

Func _testConnection()

MsgBox(64,"Quick NIC Changer", $Available_Connections)

EndFunc

Func _Exit()

Exit

EndFunc

While 1

Sleep(5000)

WEnd

[END CODE]

Tanks in advance,

Craig

Posted

You read the Control before its even filled with values. You need to do a GUICTRLREAD() when the event is triggered.

Wow it was that easy, thanks JdeB.

I am a newbee and quit qlueless with some of the stuff but thanks all the same for the quick help.

Craig

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
  • Recently Browsing   0 members

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