无法使用 AutoIt 从 Windows 窗体的下拉列表中选择值
使用以下代码
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")
它选择组合框,但没有从列表中选择所需的“这是我的默认值(测试)- 首先”。基本上,它选择以 t
开头的任何值。例如,第一个值是“TMP”。因此,它不是完全匹配,而是选择任何第一个字符匹配。如何强制它从列表中选择确切的字符串?
我也尝试使用以下代码,但似乎没有任何效果。
WinWaitActive($title)
$Index = _GUICtrlComboBoxEx_FindStringExact($hcombo, $sText)
_GUICtrlComboBoxEx_SetCurSel($hcombo, $Index)
or following
WinWaitActive($title)
$Index = _GUICtrlComboBox_FindStringExact($hcombo, $sText)
_GUICtrlComboBox_SelectString($hcombo, $Index)
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 do 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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在您使用的 ControlSend 参数不正确。下面将发送字符串“select”,最后一个参数将被评估为 0。
因为它期望 1 或 0 作为最后一个参数)。不用说这不是你想要的。
您应该使用 ControlCommand 执行类似 SelectString 的操作。您不必首先显示下拉列表:
我无法对此进行测试,但只要它找到窗口并且字符串正确,那么就应该没问题。
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.
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:
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.