Jump to content

Interaction with Dephi LookupCombo


Recommended Posts

Hello everyone, I have been using AutoIt to interact with an application written in Delphi. I have had alot of success, but there is one main problem that I dont have an elegant solution for, that I hope you can help me with.

In the application, there is a drop down list box which seems to be populated at the time that you click on the drop down box.

When I use AutoIt info, the "control tab" indicates the following;

Class : TGSLookupCombo, Instance 1, ClassnameNN : TGSLookupCombo1, Name : ,AdvancedMode : [CLASS:TGSLookupCombo;INSTANCE:1]

ID: 1510086, Text: , Position:581,454 , Size:207,21, ControlClick Coords: 123,12 , Style:0x560108C4 ,ExStyle: 0x00000200 ,

Handle: 0x00170AC6

Is there someone out there that could tell me how to read the list if items in this type of ListBox, and then select one?

Thanks in advance for any assistance you can provide.

Link to comment
Share on other sites

  • 3 weeks later...

Hello, just to let you know how I progressed with this problem.

First, here is an image of the ListBox before you click on the list expansion button at the end.

Posted Image

And here is the ListBox after you expand.

Posted Image

This is simply to assist with the explanation below.

I determined that I was able to read information about the ListBox using ControlGetText.

If I initially select the ListBox, before I click on the expansion button for the box, the unexpanded ListBoxfield allows for text to be entered, and this does a matching against items in the list associated with the ListBox.

So if you type the correct information, this then seems to bring up the entry you want, BUT not always. Some entries seem to be mis-matched.

My below code allows me to see which entry is actually currently selected in the ListBox, so I can use the pre-typing method to get 90% of the entries, and if required, followup with the Send key method to simply move through the items in the list and then do another compare again to see if we have selected the entry I am looking for.

In my code below I simply get the user to select the correct one, but the idea of going through each item is easy to implement.

I am open to any other ideas, should you like to offer?

;-------------------------------------
    ; Enter required value in LookupCombo
    ;-------------------------------------
    $readField = ControlGetText($sWinTitle,"","[CLASS:TGSLookupCombo;INSTANCE:1]")
    ; If required value is already set, then leave
    If $readField <> $value Then
        ;Click on value field
        ControlClick($sWinTitle, "", "[CLASS:TGSLookupCombo;INSTANCE:1]", "Left", 1, 1, 10)
        Send("{DEL}")
        Send($value)

        ;Confirm value field is what we expect it to be.
        $readField = ControlGetText($sWinTitle,"","[CLASS:TGSLookupCombo;INSTANCE:1]")
        If $readField <> $value Then
            ; Error, field not what we expect it to be
            MsgBox(0,"Failed automation.","Please select "& $value &" value and click OK to continue")
        EndIf
    EndIf
Edited by WSorich
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...