Jump to content

Check the value of a Combobox


Warning
 Share

Recommended Posts

How can I check the current value of my Combobox?

Current Source:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=gameaccess.kxf
$Form1 = GUICreate("Quick-Game Access!", 453, 343, 214, 125)
$Button1 = GUICtrlCreateButton("Játék Hozzáadása", 16, 8, 105, 33, 0)
$Button2 = GUICtrlCreateButton("Listát Frissít", 128, 8, 73, 17, 0)
$Button3 = GUICtrlCreateButton("Játék Törlése", 352, 8, 81, 33, 0)
$Combo1 = GUICtrlCreateCombo("Choose", 232, 8, 89, 25)
$TheLine = GUICtrlSetData(-1, "1. sor|2. sor|3. sor|4. sor|5. sor|6. sor|7. sor|8. sor|9. sor|10. sor")
$Group1 = GUICtrlCreateGroup("Játékok", 16, 48, 417, 281)
$Button4 = GUICtrlCreateButton("Button4", 56, 72, 369, 25, 0)
$Button5 = GUICtrlCreateButton("Button5", 56, 96, 369, 25, 0)
$Button6 = GUICtrlCreateButton("Button6", 56, 120, 369, 25, 0)
$Button7 = GUICtrlCreateButton("Button7", 56, 144, 369, 25, 0)
$Button8 = GUICtrlCreateButton("Button8", 56, 168, 369, 25, 0)
$Button9 = GUICtrlCreateButton("Button9", 56, 192, 369, 25, 0)
$Button10 = GUICtrlCreateButton("Button10", 56, 216, 369, 25, 0)
$Button11 = GUICtrlCreateButton("Button11", 56, 240, 369, 25, 0)
$Button12 = GUICtrlCreateButton("Button12", 56, 264, 369, 25, 0)
$Button13 = GUICtrlCreateButton("Button13", 56, 288, 369, 25, 0)
$Icon1 = GUICtrlCreateIcon("", 0, 24, 72, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$Icon2 = GUICtrlCreateIcon("", 0, 24, 96, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$Icon3 = GUICtrlCreateIcon("", 0, 24, 120, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$Icon4 = GUICtrlCreateIcon("", 0, 24, 144, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$Icon5 = GUICtrlCreateIcon("", 0, 24, 168, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$Icon6 = GUICtrlCreateIcon("", 0, 24, 192, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$Icon7 = GUICtrlCreateIcon("", 0, 24, 216, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$Icon8 = GUICtrlCreateIcon("", 0, 24, 240, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$Icon9 = GUICtrlCreateIcon("", 0, 24, 264, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
$Icon10 = GUICtrlCreateIcon("", 0, 24, 288, 25, 25, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button14 = GUICtrlCreateButton("Ico", 152, 24, 25, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$b4 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Button4","")
$n4 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Name4","")
$i4 = IniRead(@ScriptDir & "\Settings.ini", "Path", "ico4","")
$b5 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Button5","")
$n5 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Name5","")
$i5 = IniRead(@ScriptDir & "\Settings.ini", "Path", "ico5","")
$b6 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Button6","")
$n6 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Name6","")
$i6 = IniRead(@ScriptDir & "\Settings.ini", "Path", "ico6","")
$b7 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Button7","")
$n7 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Name7","")
$i7 = IniRead(@ScriptDir & "\Settings.ini", "Path", "ico7","")
$b8 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Button8","")
$n8 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Name8","")
$i8 = IniRead(@ScriptDir & "\Settings.ini", "Path", "ico8","")
$b9 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Button9","")
$n9 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Name9","")
$i9 = IniRead(@ScriptDir & "\Settings.ini", "Path", "ico9","")
$b10 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Button10","")
$n10 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Name10","")
$i10 = IniRead(@ScriptDir & "\Settings.ini", "Path", "ico10","")
$b11 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Button11","")
$n11 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Name11","")
$i11 = IniRead(@ScriptDir & "\Settings.ini", "Path", "ico11","")
$b12 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Button12","")
$n12 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Name12","")
$i12 = IniRead(@ScriptDir & "\Settings.ini", "Path", "ico12","")
$b13 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Button13","")
$n13 = IniRead(@ScriptDir & "\Settings.ini", "Path", "Name13","")
$i13 = IniRead(@ScriptDir & "\Settings.ini", "Path", "ico13","")

If $b4 = "" Then
    GUIctrlSetState($Button4, $GUI_HIDE)
EndIf

If $b5 = "" Then
    GUIctrlSetState($Button5, $GUI_HIDE)
EndIf

If $b6 = "" Then
    GUIctrlSetState($Button6, $GUI_HIDE)
EndIf

If $b7 = "" Then
    GUIctrlSetState($Button7, $GUI_HIDE)
EndIf

If $b8 = "" Then
    GUIctrlSetState($Button8, $GUI_HIDE)
EndIf

If $b9 = "" Then
    GUIctrlSetState($Button9, $GUI_HIDE)
EndIf

If $b10 = "" Then
    GUIctrlSetState($Button10, $GUI_HIDE)
EndIf

If $b11 = "" Then
    GUIctrlSetState($Button11, $GUI_HIDE)
EndIf

If $b12 = "" Then
    GUIctrlSetState($Button12, $GUI_HIDE)
EndIf

If $b13 = "" Then
    GUIctrlSetState($Button13, $GUI_HIDE)
EndIf

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Button1
    $Game = FileOpenDialog("Játék kiválasztása", "C:\", "Játék (*.exe;*.bin;*.ink)")
    Inputbox("Game-Accessor", "Mi a játék neve?", "Írd ide be....", " M", 210, 120)
    $Line = GUICtrlRead($TheLine, 1)
    msgbox(0,"", $Line)
    
EndSwitch
WEnd

$Line = GUICtrlRead($TheLine, 1)

msgbox(0,"", $Line)

In help: "Combo - List The value selected "

But it says: 0 as value...

Why?

Link to comment
Share on other sites

Try changing this line:

$Line = GUICtrlRead($TheLine, 1)

To this instead:

$Line = GUICtrlRead($Combo1, 1)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

$Combo1 is the handle (control ID) of the combo box, $TheLine is the return code of the items you added to the combobox which is either 1 or 0, trying to read control #1 is where your error was.

****Edit****

Used the wrong variable name in my explanation.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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