AutoIT - How to choose value from dropdown(combobox)

北战南征 提交于 2020-02-03 02:07:00

问题


I am automating Windows application using AutoIT.As part of this i tried to choose value from drop down, but I'm unable to select the value. Below is my code.

ControlCommand("Database Select","", "[Name:db_comboBox]", "ShowDropDown") ControlCommand("DatabaseSelect","","Name:db_comboBox]","SelectString",'Test') ControlCommand("Database Select","Main Load Settings", "[Name:db_comboBox]", "HideDropDown")

Can anyone help me how to choose value from dropdown.


回答1:


Milos, Thanks for your help and the below code solved my case.

  ControlClick("Database Select", "", "[Name:db_comboBox]")
  While 1
    Send("{DOWN}")
    $ctext=ControlGetText("Database Select","","[Name:db_comboBox]")
    If $ctext="DB_UKTEST" Then
        ExitLoop
    EndIf
  WEnd



回答2:


This worked for me ControlSend("Print", "", "ComboBox1", "[Name:Microsoft Print to PDF]")




回答3:


Example code of selecting the value in dropdown.

Run("calc.exe")

WinWait("Calculator")

$CALC = WinGetHandle("Calculator")

ControlSend($CALC, "", "[INSTANCE:1]", "^u")
WinActivate($CALC)

$index = ControlCommand($CALC,"Find String","[CLASS:ComboBox; INSTANCE:1]","FindString",'Volume')
ControlCommand($CALC, "", "[CLASS:ComboBox; INSTANCE:1]", "SetCurrentSelection", $index)

When applied to your code:

$index = ControlCommand("Database Select","", "[Name:db_comboBox]","FindString",'Test')
ControlCommand("Database Select","", "[Name:db_comboBox]", "SetCurrentSelection", $index)



回答4:


This Work For Me :

WinWaitActive ("Options (User-Mode)")
ControlCommand("Options (User-Mode)" , "" , "ComboBox1" , "SelectString" , "VNC password")


来源:https://stackoverflow.com/questions/36541929/autoit-how-to-choose-value-from-dropdowncombobox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!