Jump to content

Recommended Posts

Posted

Sorry this is such a newb question, I'm still learning the basics of autoit. For GUI, does the list control allow me to select multiple options at the same time? If not, what control would let me do that?

Posted

Sorry this is such a newb question, I'm still learning the basics of autoit. For GUI, does the list control allow me to select multiple options at the same time? If not, what control would let me do that?

You want the $LBS_MULTIPLESEL style:

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt("GuiOnEventMode", 1)
GUICreate("My GUI list", 400, 210)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$List_1 = GUICtrlCreateList("Apple", 10, 10, 290, 180, BitOR($GUI_SS_DEFAULT_LIST, $LBS_MULTIPLESEL))
$hList_1 = GUICtrlGetHandle($List_1)
GUICtrlSetData(-1, "Banana|Cherry|Guava|Kiwi|Lime|Mango|Orange|Peach|Tangerine|Ugli")
GUICtrlCreateButton("Select", 310, 50, 80, 30)
GUICtrlSetOnEvent(-1, "_Button")
GUICtrlCreateButton("Clear", 310, 130, 80, 30)
GUICtrlSetOnEvent(-1, "_Button")
GUISetState()

While 1
    Sleep(20)
WEnd

Func _Button()
    Local $avSel = _GUICtrlListGetSelItems($hList_1)
    If IsArray($avSel) Then
        Switch ControlGetText(@GUI_WinHandle, "", @GUI_CtrlHandle)
            Case "Select" 
                Local $sMsg = "Selected: " & $avSel[0] & @CRLF
                For $n = 1 To $avSel[0]
                    $sMsg &= _GUICtrlListGetText($hList_1, $avSel[$n]) & @CRLF
                Next
                MsgBox(64, "Selected", $sMsg)
            Case "Clear" 
                For $n = 1 To $avSel[0]
                    _GUICtrlListSetSel($hList_1, 0, $avSel[$n])
                Next
        EndSwitch
    EndIf
EndFunc   ;==>_Button

Func _Quit()
    Exit
EndFunc   ;==>_Quit

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

Haha, awesome example PsaltyDS! (your nick is kinda hard to spell, hehe)

thank you, that was really helpful!

Can you show me one further thing, how would I set up the list if I was using variables instead of hard strings?

Posted

thank you, that was really helpful!

Can you show me one further thing, how would I set up the list if I was using variables instead of hard strings?

Nevermind I figured it out. Again, thank you very much!!

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