Jump to content

How can I read the data of a Combo?


Recommended Posts

Trying to make sort of an incremental game for the lols, and here's my problem right now.

Keep in mind I'm a complete newbie at autoit, but I have a pretty good understanding of it, so go easy on me.

I have currently

$gems = GUICreate("Gem Seller", 219, 157, 887, 250)
$SellSelected = GUICtrlCreateButton("Sell Selected", 8, 40, 89, 25)
$Sellall = GUICtrlCreateButton("Sell all", 68, 96, 73, 25)

$Select = GUICtrlCreateCombo("Choose a Gem to sell!", 8, 8, 193, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$gemtype = GUICtrlSetData(-1, "Ruby|Emerald|Sapphire|Topaz|")

$status = _GUICtrlStatusBar_Create($gemtype)
_GUICtrlStatusBar_SetText($status, "You've selected: ")

I've added also a status bar

 

How can I read the data that GUICtrlSetData is selected? I tried

$selGUICtrlRead($gemtype) and it doesn't work.

Link to comment
Share on other sites

GUICtrlRead is fine. But you have to read the control. Means:

$sel = GUICtrlRead($Select)

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

GUICtrlRead is fine. But you have to read the control. Means:

$sel = GUICtrlRead($Select)

 

Sorry, I ment it, right now its laid out like this:

$gems = GUICreate("Gem Seller", 219, 157, 887, 250)
$SellSelected = GUICtrlCreateButton("Sell Selected", 8, 40, 89, 25)
$Sellall = GUICtrlCreateButton("Sell all", 68, 96, 73, 25)
$Select = GUICtrlCreateCombo("Choose a Gem to sell!", 8, 8, 193, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$gemtype = GUICtrlSetData(-1, "Ruby|Emerald|Sapphire|Topaz|")
$status = _GUICtrlStatusBar_Create($gemtype)
$input1 = GUICtrlRead($gemtype)
_GUICtrlStatusBar_SetText($status, "You've selected: " & $input1)

 

but it returns as 1, which I'm guessing is from the -1

 

Edit: or no, I followed the $select, but it displays "Choose a gem to sell" not the actual gems. 

 

How can I define what gem is what? I thought about maybe splitting the string?

Edited by SevereMessage
Link to comment
Share on other sites

Until you have not selected an item the default value is being returned.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Is this the whole script you posted? You need to run a loop to wait until the control has been selected.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Is this the whole script you posted? You need to run a loop to wait until the control has been selected.

It's the only part that matters right now, the other parts are way too long and unnecessary, what can I add to make it work and how can I define the strings? 

Link to comment
Share on other sites

Something like this:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Local $sComboRead = ""
Local $hGUI = GUICreate("Example", 300, 200)
Local $hComboBox = GUICtrlCreateCombo("Choose a Gem to sell!", 10, 10, 185, 20)
GUICtrlSetData($hComboBox, "Ruby|Emerald|Sapphire|Topaz")
Local $hClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)
GUISetState(@SW_SHOW, $hGUI)
; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $hClose
            ExitLoop
        Case $hComboBox
            $sComboRead = GUICtrlRead($hComboBox)
            MsgBox($MB_SYSTEMMODAL, "", "You have selected: " & $sComboRead, 0, $hGUI)
    EndSwitch
WEnd

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Something like this:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Local $sComboRead = ""
Local $hGUI = GUICreate("Example", 300, 200)
Local $hComboBox = GUICtrlCreateCombo("Choose a Gem to sell!", 10, 10, 185, 20)
GUICtrlSetData($hComboBox, "Ruby|Emerald|Sapphire|Topaz")
Local $hClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)
GUISetState(@SW_SHOW, $hGUI)
; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $hClose
            ExitLoop
        Case $hComboBox
            $sComboRead = GUICtrlRead($hComboBox)
            MsgBox($MB_SYSTEMMODAL, "", "You have selected: " & $sComboRead, 0, $hGUI)
    EndSwitch
WEnd

 

Ooh right, thank you very much, added in

_GUICtrlStatusBar_SetText($status, "You've selected: " & $Select2) in case and it works perfectly, next question how can I define Topaz, Ruby, etc?

Like

if GUiCtrlRead(Topaz)

Then

CheckAmount()

 

Link to comment
Share on other sites

What do you mean by "define"?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Case $SellSelected ; When the Sell button is pressed check which item to sell.
    $sComboRead = GUICtrlRead($hComboBox)
    If $sComboRead = "xy" Then ...

Something like this?

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Glad to be of service :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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