Jump to content

Sending a value to a combobox


Recommended Posts

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

 

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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,

Link to comment
Share on other sites

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

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