Jump to content

Recommended Posts

Posted

Is there some way to retrieve a list of strings in a ComboBox if I know the ControlID/ClassNameNN?

If I am reading the AutoIt Help File correctly, to select an option from a Control ComboBox, I need to use the following (assuming my Application Window is 'Eudora', the Control is 'ComboBox3', and the String is 'Assistant').

ControlCommand ("Eudora", "", "ComboBox3", "SelectString", 'Assistant')

Since this is not working, I must assume the string is incorrect, since I verified all the other info is correct. If that is the case, then should I assume the String name must be different than what is visible on the monitor? If so, what do I do?

Is there some way to retrieve a list of strings in a ComboBox if I know the ControlID/ClassNameNN?

Btw, this works for the control:

ControlCommand ("Eudora", "", "ComboBox3", "ShowDropDown", "")

Below is a .jpg so you get a visual. It is the ComboBox that says 'Assistant'.

  • Moderators
Posted

Well you could rule that out by, selecting Assistant from the dropdown, then run this script.

$test = ControlCommand ("Eudora", "", "ComboBox3", "GetCurrentSelection")
MsgBox(0, "", $test)
Posted

Well you could rule that out by, selecting Assistant from the dropdown, then run this script.

$test = ControlCommand ("Eudora", "", "ComboBox3", "GetCurrentSelection")
MsgBox(0, "", $test)
Thanks for the test. I am not sure if it returned a useable value. Attached is .jpg of the MsgBox. The code you will see below is just me sending the info to Notepad. But, as you will see in the .jpg one of the characters will not copy over. It is a square. Also, if I opened a new email, the result would change to something entirely different.

What kind of result does "GetCurrentSelection" return? Is it a handle, or a string, etc?

$test = ControlCommand ("Eudora", "", "ComboBox3", "GetCurrentSelection")
MsgBox(0, "", $test,1)

WinWait("Untitled","")
If Not WinActive("Untitled","") Then WinActivate("Untitled","")
WinWaitActive("Untitled","")

Send($test)
Send("{ENTER}")

  • Moderators
Posted (edited)

It returns the name of the selected item.

I have never tried this command before... but shouldn't this:
$test = ControlCommand ("Eudora", "", "ComboBox3", "GetCurrentSelection")
Be
$test = ControlCommand ("Eudora", "", "ComboBox3", "GetCurrentSelection", "")
?

Edit:

Tested it to make sure:

$gui = GUICreate('Gui')
$combo = GUICtrlCreateCombo('', 10, 10, 200)
$button = GUICtrlCreateButton('test', 10, 50)
GUICtrlSetData($combo, '1|2|3|4', '1')

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = - 3 Then Exit
    If $msg = $button Then
        MsgBox(0, 'Testing One', ControlCommand ($gui, "", 'ComboBox1', "GetCurrentSelection"));  << Throws an error
        MsgBox(0, 'Testing Two', ControlCommand ($gui, "", 'ComboBox1', "GetCurrentSelection", ""))
    EndIf
WEnd
Commenting out the 'Testing One' and it works fine. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

  • Moderators
Posted

I tested it out and it seems to work either way.

I can't imagine SciTe letting you run that... It throws me an error:

"GetCurrentLine", ""

Making the "" not optional.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

  • Moderators
Posted (edited)

I can't imagine SciTe letting you run that... It throws me an error:Making the "" not optional.

This is what I ran and it worked perfectly.

$test1 = ControlCommand ("Configure PC5250", "", "ComboBox1", "GetCurrentSelection")
$test2 = ControlCommand ("Configure PC5250", "", "ComboBox1", "GetCurrentSelection", "")
MsgBox(0, "", $test1 & @LF & $test2)
Edited by big_daddy
  • Moderators
Posted

This is what I ran and it worked perfectly.

$test1 = ControlCommand ("Configure PC5250", "", "ComboBox1", "GetCurrentSelection")
$test2 = ControlCommand ("Configure PC5250", "", "ComboBox1", "GetCurrentSelection", "")
MsgBox(0, "", $test1 & @LF & $test2)
In SciTe?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

  • Moderators
Posted

Thanks for noticing that. I did change the code to include the ,""). But, I still end up with a nonsense result, like before.

Well lets try this, select Assistant then run this script:

$a_Selected = ControlCommand ("Eudora", "", "ComboBox3", "GetCurrentSelection", "")
$a_FindSelected = ControlCommand ("Eudora", "", "ComboBox3", "FindString", $a_Selected)
MsgBox(0, "", "Occurrence: " & $a_FindSelected)

Then take the number from the MsgBox and use it with this script. Be sure and select a different item from the dropdown first:

$Occurrence = number from the MsgBox here
ControlCommand ("Eudora", "", "ComboBox3", "SetCurrentSelection", $Occurrence)
  • Moderators
Posted

Yes, version 1.67 using the beta defs.

Ahh that makes sense! They let anything pass :o

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Well lets try this, select Assistant then run this script:

$a_Selected = ControlCommand ("Eudora", "", "ComboBox3", "GetCurrentSelection", "")
$a_FindSelected = ControlCommand ("Eudora", "", "ComboBox3", "FindString", $a_Selected)
MsgBox(0, "", "Occurrence: " & $a_FindSelected)

Then take the number from the MsgBox and use it with this script. Be sure and select a different item from the dropdown first:

$Occurrence = number from the MsgBox here
ControlCommand ("Eudora", "", "ComboBox3", "SetCurrentSelection", $Occurrence)
For all 3 options it returns -1. :o

Let me take this a different direction for a moment. Take a look at the photo on the original post. There is a 'button'/'ComboBox' titled "From". It is right under the "To" text. What is the "From" called? Is that a ComboBox, or something else?

Posted

For all 3 options it returns -1. :geek:

Well holy crap! I was trying to figure something else out, and then I realized that there is a discrepancy or misunderstanding on my part. And, the good news, is that big_daddy's script gave me an answer to my problem! Yea! :o

I found out that the ComboBox3 works as 0,1,2. I came across the info on accident, because of a typo on my part, that resulted in the right answer. How weird. LOL!

My next problem is trying to figure out how the heck that "From" button/ComboBox works. Any ideas?

It just returns the value ''0' When I run your script, no matter what I choose.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...