Sign in to follow this  
Followers 0
littlebigman

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

5 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

I think it's waiting (and will be waiting until the end of time) for a window with this title: classname=TfrmHome.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Thanks for the help.

You bet. Good luck with the rest of your project.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
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
Sign in to follow this  
Followers 0