Sign in to follow this  
Followers 0
pgv

Selecting an Item from a ComboBox

11 posts in this topic

Hi Experts

How do I select a particular item from comboBox

currently I am using the following code.

;$a =ControlCommand("Select User or Group","","1032","Selectstring","abc")

$a=ControlClick("Select User or Group","","Button9[,Click]")

the strings and id's I got are by using autoit win info

any help is greatly appreciated

Share this post


Link to post
Share on other sites



Hi Experts

How do I select a particular item from comboBox

currently I am using the following code.

;$a =ControlCommand("Select User or Group","","1032","Selectstring","abc")

$a=ControlClick("Select User or Group","","Button9[,Click]")

the strings and id's I got are by using autoit win info

any help is greatly appreciated

Can you say what the problem is with

$a =ControlCommand("Select User or Group","","1032","Selectstring","abc")
?

This line

$a=ControlClick("Select User or Group","","Button9[,Click]")

should be

$a=ControlClick("Select User or Group","","Button9")

The square brackets [,Clicks] means that the parameter clicks is optional so you don't have to include it. If you don't include it then it is assumed that the number of times to click is 1 (the default). If you do include it you have to use the number of clicks like this

$a=ControlClick("Select User or Group","","Button9",2);for 2 clicks

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I have made some changes...

Thanks for the suggestions, applied the code you suggested but does not click on the item required in the comboBox. I have made some changes to the code..

$pText = "Select User or Groups"

$hListView1 = ControlGetHandle($pText, "", "[CLASS:ComboBox;INSTANCE:1]")

$cblist=_GUICtrlComboBox_GetList($hListView1)

For $j= 0 to $cblist -1

$cbarr=_GUICtrlComboBox_GetListArray ($hListView1)

sleep(2000)

MsgBox(1, "", _ArrayToString($cbarr, "",1,1))

Msgbox(1,"",$cblist)

Next

Any help is much appreciated.

pgv

Can you say what the problem is with

$a =ControlCommand("Select User or Group","","1032","Selectstring","abc")
?

This line

$a=ControlClick("Select User or Group","","Button9[,Click]")

should be

$a=ControlClick("Select User or Group","","Button9")

The square brackets [,Clicks] means that the parameter clicks is optional so you don't have to include it. If you don't include it then it is assumed that the number of times to click is 1 (the default). If you do include it you have to use the number of clicks like this

$a=ControlClick("Select User or Group","","Button9",2);for 2 clicks

Share this post


Link to post
Share on other sites

all I am doing is to clikc on a particular item in a combobox

ControlClick("Select User or Group", "","[CLASS:ComboBox;INSTANCE:1]") {THIS WILL CLICK ON THE COMBOBOX}

USING THE FUNTION BELOW IA M TRYING GET THE ITEM LIST AND THEN PICK ONE ITEM FROM THE LIST OF ITEMS

----------------------------------------------------------------------------------------------------

Func _cmb()

$pText = "Select User or Groups"

$cmbview = ControlGetHandle($pText, "", "[CLASS:ComboBox;INSTANCE:1]")

$l=_GUICtrlComboBox_GetList($pText)

MsgBox(1,"",$l)

$res=_GUICtrlComboBox_FindString($cmbview,"abc")

msgbox(1,"",$res)

Sleep(2000)

;Msgbox(1,"",$cblist)

EndFunc

Please see attachement , I am trying to select one of the domain among the 6 in the drop down list

-------------------------------------

I have made some changes...

Thanks for the suggestions, applied the code you suggested but does not click on the item required in the comboBox. I have made some changes to the code..

$pText = "Select User or Groups"

$hListView1 = ControlGetHandle($pText, "", "[CLASS:ComboBox;INSTANCE:1]")

$cblist=_GUICtrlComboBox_GetList($hListView1)

For $j= 0 to $cblist -1

$cbarr=_GUICtrlComboBox_GetListArray ($hListView1)

sleep(2000)

MsgBox(1, "", _ArrayToString($cbarr, "",1,1))

Msgbox(1,"",$cblist)

Next

Any help is much appreciated.

pgv

post-48074-1239980614_thumb.jpg

Share this post


Link to post
Share on other sites

$cmbview = ControlGetHandle($pText, "", "[CLASS:ComboBox;INSTANCE:1]")

MsgBox(1,"",$cmbview)

$bb=_GUICtrlComboBox_SetCurSel($cmbview,5)

This will get me the selection on other combobox but does not do it for the combobox shown in the attachment. Any ideas

all I am doing is to clikc on a particular item in a combobox

ControlClick("Select User or Group", "","[CLASS:ComboBox;INSTANCE:1]") {THIS WILL CLICK ON THE COMBOBOX}

USING THE FUNTION BELOW IA M TRYING GET THE ITEM LIST AND THEN PICK ONE ITEM FROM THE LIST OF ITEMS

----------------------------------------------------------------------------------------------------

Func _cmb()

$pText = "Select User or Groups"

$cmbview = ControlGetHandle($pText, "", "[CLASS:ComboBox;INSTANCE:1]")

$l=_GUICtrlComboBox_GetList($pText)

MsgBox(1,"",$l)

$res=_GUICtrlComboBox_FindString($cmbview,"abc")

msgbox(1,"",$res)

Sleep(2000)

;Msgbox(1,"",$cblist)

EndFunc

Please see attachement , I am trying to select one of the domain among the 6 in the drop down list

-------------------------------------

Share this post


Link to post
Share on other sites

$cmbview = ControlGetHandle($pText, "", "[CLASS:ComboBox;INSTANCE:1]")

MsgBox(1,"",$cmbview)

$bb=_GUICtrlComboBox_SetCurSel($cmbview,5)

This will get me the selection on other combobox but does not do it for the combobox shown in the attachment. Any ideas

Please use the ControlID # in the ControlGethandle method instead of "[CLASS:ComboBox;INSTANCE:1]", It works for me

Share this post


Link to post
Share on other sites

thanx for the response..

$han = ControlGetHandle($pText, "", "0x002E0330")

MsgBox(1,"",$han)

I have chnaged it to the above but it is not giving any msgbox now ....any thing I am missing..

Please use the ControlID # in the ControlGethandle method instead of "[CLASS:ComboBox;INSTANCE:1]", It works for me

Share this post


Link to post
Share on other sites

thanx for the response..

$han = ControlGetHandle($pText, "", "0x002E0330")

MsgBox(1,"",$han)

I have chnaged it to the above but it is not giving any msgbox now ....any thing I am missing..

The control id referred to was ID in Summary tab of the Basic window info for the checkbox. eg...ControlGetHandle($pText,"",1061)

Share this post


Link to post
Share on other sites

as suggested I have changed it

$han = ControlGetHandle($pText,"",1005)

MsgBox(1,"www",$han)

_GUICtrlComboBox_SetCurSel($han,6)

but still no luck, the msgbox does not display the handle id

The control id referred to was ID in Summary tab of the Basic window info for the checkbox. eg...ControlGetHandle($pText,"",1061)

Share this post


Link to post
Share on other sites

as suggested I have changed it

$han = ControlGetHandle($pText,"",1005)

MsgBox(1,"www",$han)

_GUICtrlComboBox_SetCurSel($han,6)

but still no luck, the msgbox does not display the handle id

whether you changed the $pText value, it should be "Select user or Group" with reference to the screenshot attached...

Share this post


Link to post
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
Sign in to follow this  
Followers 0