Unable to select a value from a dropdown of windows form using AutoIt
Using the following code
ControlCommand("Test Form", "", "[NAME:ctlMsgQueueCombo]", "ShowDropDown")
ControlSend("Test Form", "", "[NAME:ctlMsgQueueCombo]", "This is my default value (TEST) - First")
or
ControlCommand("Test Form", "", "[NAME:ctlMsgQueueCombo]", "ShowDropDown")
ControlSend("Test Form", "", "[NAME:ctlMsgQueueCombo]", "select", "This is my default value (TEST) - First")
It selects the combo box, but it is not selecting the desired "this is my default value (TEST) - First" from the list. Basically, it is selecting any value that starts with t
. For example, the first value is "TMP". So instead of exactly matching it is selecting any first character match. How d开发者_JAVA技巧o I force it to select the exact string from the list?
I also tried using the following code, but nothing seems to work.
WinWaitActive($title)
$Index = _GUICtrlComboBoxEx_FindStringExact($hcombo, $sText)
_GUICtrlComboBoxEx_SetCurSel($hcombo, $Index)
or following
WinWaitActive($title)
$Index = _GUICtrlComboBox_FindStringExact($hcombo, $sText)
_GUICtrlComboBox_SelectString($hcombo, $Index)
Right now you are using ControlSend with incorrect parameters. The following will send the string 'select', and the last parameter will be evaluated to 0.
ControlSend("Test Form", "", "[NAME:ctlMsgQueueCombo]", "select", "This is my default value (TEST) - First")
As it expects 1 or 0 as the last parameter). Needless to say it's not what you want.
You should be doing something like SelectString with ControlCommand. You shouldn't have to show the dropdown first:
ControlCommand("Test Form", "", "[NAME:ctlMsgQueueCombo]", "SelectString", "This is my default value (TEST) - First")
I haven't been able to test that, but as long as it's finding the window and the string is correct then it should be fine.
精彩评论