问题
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