Jump to content

How to get contents from a combo box


Recommended Posts

I used the ControlGetText command to get the contents from a combo box, but it failed to bring back the contents (see code below). Is there any other way of doing this please?

;Search for Affidavit of Non-military service letter template

ControlSend("CLMS - Northbook Technology - Magee Campus - [<< Main CLMS >>]", "", "ComboBox1",'{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}

{Down}{Down}{Down}{Down}{Down}{Down}{Down}')

$letterTemplate = ControlGetText("CLMS - Northbook Technology - Magee Campus - [<< Main CLMS >>]", "", "ComboBox1")

sleep(2000)

If $letterTemplate <> "Affidavit of Non-military service" Then

MsgBox(48, "Error Found", "Affidavit of Non-military service letter template failed to exist (therefore letter failed to generate)")

EndIf

Link to comment
Share on other sites

  • Developers

I'd like to, but I can't understand the problem.

<{POST_SNAPBACK}>

Believe that this is the issue described:

Run below demo code and the msgbox returns "item1".

How can it be checked if item3 is in the list?

#include <GUIConstants.au3>
GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered
GUICtrlCreateCombo ("item1", 10,10); create first item
GUICtrlSetData(-1,"item2|item2|item3","item1"); add other item snd set a new default
GuiSetState ()
$Item = ControlGetText("My GUI combo",'','Edit1')
MsgBox(4096,'debug:' , '$Item:' & $Item);### Debug MSGBOX 
Exit

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

... using a variant. I guess I still misunderstanding.

#include <GUIConstants.au3>
GUICreate("My GUI combo"); will create a dialog box that when displayed is centered
GUICtrlCreateCombo ("item1", 10,10); create first item
$list = "item2|item2|item3"
$default = "item1"
GUICtrlSetData(-1,$list,$default); add other item snd set a new default
GuiSetState ()
$Item = ControlGetText("My GUI combo",'','Edit1')
MsgBox(4096,'debug:' , '$Item:' & $Item);### Debug MSGBOX 
;Use a stringinstr()
Exit
Link to comment
Share on other sites

  • Developers

... using a variant. I guess I still misunderstanding.

<{POST_SNAPBACK}>

Yes...

How can it be checked if item3 is in the list?

in other words: How can an AutoIt script check if a particular value (in this case item3) exists as an option in the Combobox.

i guess i expected the below code to work but it doesn't and i don't know why...

#include <GUIConstants.au3>
GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered
GUICtrlCreateCombo ("item1", 10,10); create first item
GUICtrlSetData(-1,"item2|item2|item3","item1"); add other item snd set a new default
GuiSetState ()
$Item = ControlGetText("My GUI combo",'','Edit1')
MsgBox(4096,'debug:' , '$Item:' & $Item);### Debug MSGBOX 
$ret=ControlCommand ("My GUI combo",'','Edit1', "FindString", 'item3' )
Msgbox(0,'@error',@error)
Msgbox(0,'$ret',$ret)
Exit

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I'm searching through a list in a combo box for a certain file called "Affidavit of Non-military service". I know it is the 23rd one down in the list, when i get to it I want to confirm that this is the correct file, by trying to get the contents in the combo box.

ControlGetText does not work for this. Do you please know of another way to get the text so I can compare it to find out if the correct file was retrieved?

Link to comment
Share on other sites

  • Developers

I'm searching through a list in a combo box for a certain file called "Affidavit of Non-military service".  I know it is the 23rd one down in the list, when i get to it I want to confirm that this is the correct file, by trying to get the contents in the combo box. 

ControlGetText does not work for this.  Do you please know of another way to get the text so I can compare it to find out if the correct file was retrieved?

<{POST_SNAPBACK}>

Understood your issue...

What about doing a ControlsetText() to this requested value and the do a ControlGettext() to see if it selected it?

Like:

#include <GUIConstants.au3>
GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered
GUICtrlCreateCombo ("item1", 10,10); create first item
GUICtrlSetData(-1,"item2|item2|item3","item1"); add other item snd set a new default
GuiSetState ()
ControlSetText("My GUI combo",'','Edit1',"item3")
$Item = ControlGetText("My GUI combo",'','Edit1')
MsgBox(4096,'debug:' , '$Item:' & $Item);### Debug MSGBOX

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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