Jump to content

[Combobox] Right way to put focus + select item?


Recommended Posts

Hello

I'm an AutoIT newbie, and need to select an item in a combobox. I googled for this, but would like to check what's the right way to solve this.

The combobox control I need to click on and select an item from is class=TbsSkinOfficeComboBox.

Should I use this, or is there a better way?

;Which should I choose?

#include <GUIConstantsEx.au3>
GUICtrlSetState("TbsSkinOfficeComboBox",$GUI_FOCUS)


;or
ControlCommand("My GUI", "", "[CLASS:TbsSkinOfficeComboBox; INSTANCE:1]", "SelectString", "item2")

Thank you.

Link to comment
Share on other sites

I made a bit of progress understanding how AutoIT works with controls, but the following code doesn't work: The script just waits doing nothing, although the application is running with its window maximized:

#region --- Internal functions Au3Recorder Start ---

Func _Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
WinWait($title,$text,$timeout)
If Not WinActive($title,$text) Then WinActivate($title,$text)
WinWaitActive($title,$text,$timeout)
EndFunc

_AU3RecordSetup()
#endregion --- Internal functions Au3Recorder End ---

_WinWaitActivate("classname=TfrmHome","")
ControlClick("[CLASS:TfrmHome]", "", "[ID:2164966]")

Can someone spot what's wrong with the above?

Thank you.

Edited by littlebigman
Link to comment
Share on other sites

Thanks for the help. I found what it was: The following code as generated by Au3Recorder doesn't work:

_WinWaitActivate("classname=TfrmHome","",5)

This works:

;time out after 10s
;BAD _WinWaitActivate("classname=TfrmHome","",5)
_WinWaitActivate("[CLASS:TfrmHome]","",5)

Send("{ALTDOWN}a{ALTUP}")
MsgBox(64, "My title", "My text")

Bottom line: Although it should be a great help for newbies to get started with AutoIT, Au3Recorder is to be avoided.

Thank you.

Edited by littlebigman
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...