litlmike Posted March 9, 2006 Posted March 9, 2006 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'. _ArrayPermute()_ArrayUnique()Excel.au3 UDF
Moderators big_daddy Posted March 9, 2006 Moderators Posted March 9, 2006 Well you could rule that out by, selecting Assistant from the dropdown, then run this script. $test = ControlCommand ("Eudora", "", "ComboBox3", "GetCurrentSelection") MsgBox(0, "", $test)
litlmike Posted March 9, 2006 Author Posted March 9, 2006 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}") _ArrayPermute()_ArrayUnique()Excel.au3 UDF
Moderators big_daddy Posted March 9, 2006 Moderators Posted March 9, 2006 What kind of result does "GetCurrentSelection" return? Is it a handle, or a string, etc?It returns the name of the selected item.
Moderators SmOke_N Posted March 9, 2006 Moderators Posted March 9, 2006 (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 WEndCommenting out the 'Testing One' and it works fine. Edited March 9, 2006 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 big_daddy Posted March 9, 2006 Moderators Posted March 9, 2006 I tested it out and it seems to work either way.
Moderators SmOke_N Posted March 9, 2006 Moderators Posted March 9, 2006 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 big_daddy Posted March 9, 2006 Moderators Posted March 9, 2006 (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 March 9, 2006 by big_daddy
Moderators SmOke_N Posted March 9, 2006 Moderators Posted March 9, 2006 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.
litlmike Posted March 9, 2006 Author Posted March 9, 2006 I can't imagine SciTe letting you run that... It throws me an error:Making the "" not optional.Thanks for noticing that. I did change the code to include the ,""). But, I still end up with a nonsense result, like before. _ArrayPermute()_ArrayUnique()Excel.au3 UDF
Moderators big_daddy Posted March 9, 2006 Moderators Posted March 9, 2006 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 big_daddy Posted March 9, 2006 Moderators Posted March 9, 2006 In SciTe?Yes, version 1.67 using the beta defs.
Moderators SmOke_N Posted March 9, 2006 Moderators Posted March 9, 2006 Yes, version 1.67 using the beta defs.Ahh that makes sense! They let anything pass 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.
litlmike Posted March 9, 2006 Author Posted March 9, 2006 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. 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? _ArrayPermute()_ArrayUnique()Excel.au3 UDF
litlmike Posted March 9, 2006 Author Posted March 9, 2006 For all 3 options it returns -1. 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! 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. _ArrayPermute()_ArrayUnique()Excel.au3 UDF
Moderators big_daddy Posted March 9, 2006 Moderators Posted March 9, 2006 Maybe this script could provide you with some more info.
litlmike Posted March 10, 2006 Author Posted March 10, 2006 Maybe this script could provide you with some more info.Been there, done that. Works well for most things, but in the unique situations, it is just 1-2 steps short. I put in some suggestions on that post. Mainly, a Copy All feature. I wish I knew how to do it. _ArrayPermute()_ArrayUnique()Excel.au3 UDF
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now