NeilClough Posted June 4, 2014 Posted June 4, 2014 Hi All, I am having problems setting/selecting a value in a ComboBox. 1. I have looked at similar questions in previous posts, but I am still not sure what is the best/correct method to select a vaule in a combobox? Is it "ControlSetText" or "ControlCommand" ? 2. Either way, I can't get it to work !! I have: $Result = ControlSetText(...) or $Result = Controlcommand(...) and they both return $Result = 1, but the value in the ComboBox is not changed. I have checked that I have the correct controID by using a ControlGetText() command. Thanks, Neil
Danp2 Posted June 4, 2014 Posted June 4, 2014 Looks like ControlCommand is the proper way to set the ComboBox selection. Post your code and perhaps someone will have an idea of why it isn't working for you. Latest Webdriver UDF Release Webdriver Wiki FAQs
NeilClough Posted June 4, 2014 Author Posted June 4, 2014 Hi Danp2, I don't think the code will be of much help - as I stated AutoIT thinks the code is ok. $Result = ControlCommand("Window Title","","[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a1]","SelectString","Draft") $Result = ControlSetText("Window Title","","[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a1]","Draft") AutoIt returns $Result = 1 for both options. and as stated, I think I have the correct ControID details, as this command returns a correct value: $Result = ControlGetText("Window Title","","[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a1]") Thanks
Danp2 Posted June 4, 2014 Posted June 4, 2014 Actually, the code helped a lot because it shows that you are trying to interact with a WindowsForm / DotNet application. You should use the forum search functions to look for similar threads to see if the posted solution works for you. One possible option is >here. Latest Webdriver UDF Release Webdriver Wiki FAQs
NeilClough Posted June 4, 2014 Author Posted June 4, 2014 Hi Danp2 Thanks again for advice. I did do a search before original post but too many hits and I wasn't sure about what specific things I should look for. I didn't realise that being a Windows form was an issue. I did another search and found: #include <GuiComboBox.au3> $hWnd=ControlGetHandle("AVEVA PDMS Login", "", "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a1]") _GUICtrlComboBox_SelectString($hWnd, "Draft") which is exactly what I need. Thanks very much. Neil
Danp2 Posted June 5, 2014 Posted June 5, 2014 You're welcome! Glad you found something that works for you. Latest Webdriver UDF Release Webdriver Wiki FAQs
NeilClough Posted June 5, 2014 Author Posted June 5, 2014 Oops !! Spoke too soon :-( _GUICtrlComboBox_SelectString($hWnd, "Draft") This code sets the required value in the ComboBox ok, but the form doesn't recognise this change when I press the "go" button. It still uses the value that was displayed before the change. I've tried sending a "right click",TAB or Enter but nothing forces the form to recognise the new value. ControlGetText() returns the new value ok !! Any suggestions? Thanks, Neil
Danp2 Posted June 5, 2014 Posted June 5, 2014 You may want to try the IUIAutomation solution. Latest Webdriver UDF Release Webdriver Wiki FAQs
NeilClough Posted June 5, 2014 Author Posted June 5, 2014 OK I did actually have a look at this from your earlier post, but I couldn't really understand what it was all about. It appeared to be mainly about interacting with web browsers. Looks like I'll have to investigate further. Thanks,
ilynaf Posted June 6, 2014 Posted June 6, 2014 Oops !! Spoke too soon :-( _GUICtrlComboBox_SelectString($hWnd, "Draft") This code sets the required value in the ComboBox ok, but the form doesn't recognise this change when I press the "go" button. It still uses the value that was displayed before the change. I've tried sending a "right click",TAB or Enter but nothing forces the form to recognise the new value. ControlGetText() returns the new value ok !! Any suggestions? Thanks, Neil Your code works for me. Here is the control class: WindowsForms10.COMBOBOX.app.0.16983f6_r69_ad1
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