Jump to content

Button and Combo box


Arnol5
 Share

Go to solution Solved by jdelaney,

Recommended Posts

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

 
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Solution

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

If not, provide the entire script.

Edited by jdelaney
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.
Link to comment
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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
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

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