Sign in to follow this  
Followers 0
Arnol5

Button and Combo box

6 posts in this topic

Hello

When i press the button i want it to read witch language i selected but it gives me an error that it doesn't understand Dutch,French,English,German

So what does the GUICtrlRead give as outpout ?

$Combo1 = GUICtrlCreateCombo("Server language", 32, 8, 113, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Dutch|French|English|German")
Func button1()
   $var = GUICtrlRead($combo1)
   if $var = Dutch Then
      MsgBox(0,"blub","hell yeah")
      EndIf
   EndFunc

thx in advance

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi Arnol5

  I wouldn't use a Function for this. Use Select Case.

Actually just use the example in the help file and change it a little for your purpose.

Bill

Edit: to answer your question- GUICtrlRead will read the control you feed it.

But you are not calling your function anywhere.

Edited by l3ill

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

; assuming you are calling the function correctly:
if $var = "Dutch" Then

If not, provide the entire script.

Edited by jdelaney
1 person likes this

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global Const $hGUI = GUICreate("Test", 300, 200)
Global Const $iCombo1 = GUICtrlCreateCombo("Server language", 10, 8, 113, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Dutch|French|English|German")
Global Const $iBtn = GUICtrlCreateButton("Check" & @CRLF & "Combo", 10, 50, 50, 50, $BS_MULTILINE)
GUISetState()

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
        Case $iBtn
            (GUICtrlRead($iCombo1) = "Dutch") ? MsgBox(0,"blub","hell yeah") : ""
    EndSwitch
Until False

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Arnol5,

In case you are not aware of this.  When you click on an entry in a listbox (combobox) the control is actioned so...

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>

#AutoIt3Wrapper_Add_Constants=n

local $gui010 = guicreate('')
$Combo1 = GUICtrlCreateCombo("Server language", 32, 8, 113, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Dutch|French|English|German")
guisetstate()

while 1
    switch guigetmsg()
        case $gui_event_close
            Exit
        case $Combo1
            msgbox(0,'',guictrlread($Combo1))
    EndSwitch
WEnd

Also, the code that UEZ posted requires 3.3.10

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

I Forgot the "   " 

Thx for the fast and good respons everyone

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