Sign in to follow this  
Followers 0
psgame_freak

Does combo box work with GUI OnEventMode?

5 posts in this topic

If so, can I get a sample please.

I want to control my program depending on what option was selected on the combo box. And that's all I need the GUI for.

So basically:

1) Program starts with combo box

2) User selects an option

3) program starts according to option chosen on combo box.

4) The GUI sits there in case user wants to change his option.

Share this post


Link to post
Share on other sites



I think you want something like this?

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
GUICreate("Combo Test", 120, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState(@SW_SHOW)

$combo = GUICtrlCreateCombo("", 30, 30, 60, 20)
GUICtrlSetOnEvent($combo, "check")
GUICtrlSetData($combo, "One|Two|Three", "One")

Func check()
    $item = GUICtrlRead($combo)
    Select
        Case $item = "One"
            MsgBox(0, "", "This is One")
        Case $item = "Two"
            MsgBox(0, "", "This is Two")
        Case $item = "Three"
            MsgBox(0, "", "This is Three")
    EndSelect
EndFunc

Func close()
    Exit
EndFunc

While 1
    Sleep(1000)
WEnd

Share this post


Link to post
Share on other sites

I think you want something like this?

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
GUICreate("Combo Test", 120, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState(@SW_SHOW)

$combo = GUICtrlCreateCombo("", 30, 30, 60, 20)
GUICtrlSetOnEvent($combo, "check")
GUICtrlSetData($combo, "One|Two|Three", "One")

Func check()
    $item = GUICtrlRead($combo)
    Select
        Case $item = "One"
            MsgBox(0, "", "This is One")
        Case $item = "Two"
            MsgBox(0, "", "This is Two")
        Case $item = "Three"
            MsgBox(0, "", "This is Three")
    EndSelect
EndFunc

Func close()
    Exit
EndFunc

While 1
    Sleep(1000)
WEnd
Yes! Thank you.

One big problem though.

My code looks exactly like yours now but I get error "Select" statement is missing "EndSelect" or "Case" statement.

Is there a limit on how many cases are there? Because I have 21.

And does it matter where everything is? Like, do function need to be above the infinite loop?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I don't know about a limit with Select, but I'm sure it wouldn't be as low as 21. I'd think it's an error in your script.

The order of certain things does matter. I've noticed the loop can be before personally created functions, but not before external functions and items like guicreate... It's easy enough just to make it last. :whistle:

I'm actually brandnew to Autoit, so I may be wrong. I've started picking it up pretty quick, though, because of the amazing help file.

Edited by xcal

Share this post


Link to post
Share on other sites

I know what I did wrong.

Don't name a variable select if you're going to use it inside While...WEnd

Share this post


Link to post
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
Sign in to follow this  
Followers 0