Jump to content

Listbox to set value in label


Recommended Posts

$Form1 = GUICreate("Form1", 394, 197, 192, 124)
GUICtrlCreateInput("", 32, 32, 329, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Button1", 56, 80, 97, 33)
$Button2 = GUICtrlCreateButton("Button2", 216, 80, 113, 33)

$List1 = GUICtrlCreateList("", 24, 120, 337, 58)
GUICtrlSetData(-1, "test|test2|test3|test4|test5")
GUISetState(@SW_SHOW)





While 1

    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Or $msg = $Button2 Then

        Exit
    EndIf

    If $msg = $Button1 Then

Call ("functiontest")

EndIf
WEnd





Func functiontest ()





Local $oIE = _IECreate ("http://www.test.com")



Local $text1 = _IEGetObjByName ($oIE,"Textbox")

_IEFormElementSetValue ($text1, "VALUEINPUTHERE")





EndFunc

here my code,

i have made a basic gui with button and listbox.

 

i would like that when i select the value of listbox and click on the button, the value will appear here

_IEFormElementSetValue ($text1, "VALUEINPUTHERE")

at the moment will not appear one of this 

test|test2|test3|test4|test5

 

but appear this number.....6

 

thank you fot the help

Link to comment
Share on other sites

Use GUICtrlRead to read from the list.

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

Help file has plenty of examples, have you looked at it?

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

#include <IE.au3>
#include <ColorConstants.au3>

$Form1 = GUICreate("Form1", 394, 197, 192, 124)
GUICtrlCreateInput("", 32, 45, 329, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Button1", 56, 80, 97, 33)
$Button2 = GUICtrlCreateButton("Button2", 216, 80, 113, 33)
$label = GUICtrlCreateLabel("Starstar",120,1,150,40)
$List1 = GUICtrlCreateList("", 24, 120, 337, 58)
GUICtrlSetCursor($label, 0)
GUICtrlSetColor($label, $COLOR_White)
GUICtrlSetFont($label,30,100)
GUICtrlSetData($List1, "test|test2|test3|test4|test5")
GUISetState(@SW_SHOW)





While 1

    $msg = GUIGetMsg()

    If $msg = -3 Or $msg = $Button2 Then

        Exit
    EndIf
If $msg = $label Then
        ShellExecute("https://www.autoitscript.com/forum/profile/76662-starstar/")
        EndIf
    If $msg = $Button1 Then

$ListRead = GUICtrlRead($List1)
    Switch $ListRead
        Case "test"
            MsgBox(0,"Starstar","You are selected test")
            Case "test2"
            MsgBox(0,"Starstar","You are selected test2")
            Case "test3"
            MsgBox(0,"Starstar","You are selected test3")
            Case "test4"
            MsgBox(0,"Starstar","You are selected test4")
            Case "test5"
            MsgBox(0,"Starstar","You are selected test5")
    EndSwitch
    Sleep(10)
Call ("functiontest")
EndIf
WEnd





Func functiontest ()





Local $oIE = _IECreate ("http://www.test.com")



Local $text1 = _IEGetObjByName ($oIE,"Textbox")

_IEFormElementSetValue ($text1, "VALUEINPUTHERE")





EndFunc

Here is an example of GuiCtrlRead() in your script.........Select an item from your list and than press Button1 and look......

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

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