Jump to content

How do you get the text return in a Listbox?


Recommended Posts

$SelectList = GUICtrlCreateList("", 48, 88, 121, 77, -1, 0)
GUICtrlSetData(-1, "1. Auto Fighter|2. Power Cutter|3. Power Fisher|4. Power Miner")

Global $selection = 0
Global $selectiondecipher = GUICtrlRead($SelectList)

Func Selection()
    While 1
    $msg = GUIGetMsg
    Select
        Case $msg = $NextButton
        $username = GUICtrlRead($UsernameInput)
        $password = GUICtrlRead($PasswordInput)
        
        If $selectiondecipher = "1. Auto Fighter" Then
            $selection = 1
        Endif

        
        If $selectiondecipher = "2. Power Cutter" Then
            $selection = 2
        Endif   
        
        If $selectiondecipher = "3. Power Fisher" Then
            $selection = 3
        Endif   
        
        If $selectiondecipher = "4. Power Miner" Then
            $selection = 4
        Endif   
        
        
            
    EndSelect   
    Wend
EndFunc

This is what I'm trying to do, but it says error. I read the help file and it said I should use GUICtrlRead, but GUICtrlRead doesn't work with GUICtrlSetData. Any help would be greatly appreciated. =)

Edited by inline853
Link to comment
Share on other sites

Like this....

#include <GUIConstants.au3>

GUICreate("")
$SelectList = GUICtrlCreateList("", 48, 88, 121, 77, -1, 0)
GUICtrlSetData(-1, "1. Auto Fighter|2. Power Cutter|3. Power Fisher|4. Power Miner")
GUISetState()

While 1
    
    $msg = GUIGetMsg()
    
    If $msg = $SelectList Then MsgBox(0x0, "test", GUICtrlRead($SelectList), 2)
    
    If $msg = -3 Then Exit
    
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

but im using Global $selectiondecipher = GUICtrlRead($SelectList) to get $selectiondecipher as a variable representing text, andf it isn't working. how can i get the variable to = the text? that was my question. or what my question was supposed to be.

Link to comment
Share on other sites

this what you're looking for?

#include <GuiConstants.au3>
#include <GUIList.au3>

$parent = GUICreate("List",400,200)

$SelectList = GUICtrlCreateList("", 10, 10, 121, 77, -1, 0)
GUICtrlSetData($SelectList,"1. Auto Fighter|2. Power Cutter|3. Power Fisher|4. Power Miner")
GuiCtrlCreateLabel("Username",150,10,50,25)
GuiCtrlCreateLabel("Password",150,40,50,25)
$UsernameInput = GuiCtrlCreateInput("",200,10,100,20)
$PasswordInput = GuiCtrlCreateInput("",200,40,100,20)
$NextButton = GuiCtrlCreateButton("Select",150,100,75,25)

Global $selection = 0
Global $selectiondecipher = GUICtrlRead($SelectList)

GUISetState()
Do
$msg = GUIGetMsg()


    Select
        Case $msg = $NextButton
        $username = GUICtrlRead($UsernameInput)
        $password = GUICtrlRead($PasswordInput)
        $selectedindex = _GUICtrlListSelectedIndex($SelectList)
        $selected = _GUICtrlListGetText($SelectList,$selectedindex)
        If $selected = "1. Auto Fighter" Then
            $selection = 1
        Endif

        
        If $selected = "2. Power Cutter" Then
            $selection = 2
        Endif   
        
        If $selected = "3. Power Fisher" Then
            $selection = 3
        Endif   
        
        If $selected = "4. Power Miner" Then
            $selection = 4
        Endif
        MsgBox(0,"Selected","You selected " & $selected)
    EndSelect   

Until $msg = $GUI_EVENT_CLOSE
GUIDelete()
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

now when i click the $NextButton, it doesn't open the other GUI. I set it up like this ...

Func Selection()
    While 1
    $selectedindex = _GUICtrlListSelectedIndex($SelectList)
    $selected = _GUICtrlListGetText($SelectList,$selectedindex)

    $msg = GUIGetMsg()
    Select
        
        Case $msg = $NextButton
        $username = GUICtrlRead($UsernameInput)
        $password = GUICtrlRead($PasswordInput)
        
        If $selected = "1. Auto Fighter" Then
            $selection = 1
        Endif
        
        If $selected = "2. Power Cutter" Then
            $selection = 2
        Endif    
        
        If $selected = "3. Power Fisher" Then
            $selection = 3
        Endif    
        
        If $selected = "4. Power Miner" Then
            $selection = 4
        Endif

            
    EndSelect   
    WendoÝ÷ Ù«­¢+Ù%ÀÌØíͱѥ½¸ôÀQ¡¸(%U%MÑMÑÑ¡M]}M!=¤)¹¥)%ÀÌØíͱѥ½¸±ÐìÐìÀQ¡¸(%U%±Ñ ÀÌØí5¥¸¤)¹¥oÝ÷ ÚØb²+-¢^Ø^¢Ø^¬ejëh×6If $selection = 4 then 
    GUISetState(@SW_SHOW);<== Sets the GUI to be Visible
endif

It is supposed to open another GUI when the user selects the 4th option. In this process it also shuts itself down.

Any help?

Edited by inline853
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...