Sign in to follow this  
Followers 0
bmccollum

How to Tell if A Form is *Really* Ready to be Controlled by AutoIt Script?

1 post in this topic

I have a 3rd party desktop application that I've written extensive AutoIt scripting to control, opening various screens within the application, clicking on command buttons, selecting values in drop-down boxes, etc.

One particular form takes a few seconds to open due to a dynamic population of server names occurring for a specific drop-down control on the form.

The issue I'm having is that my AutoIt script is determining that the form itself is open and accessible, so it continues to move forward to click a command button in that form when the server names have yet to be populated within an associated drop-down box on the form.  The command button to be clicked is "Connect", which basically tells the application to establish a connection to a SQL Server instance selected in the drop-down box in order for us to be able to see a list of databases present in the SQL Server instance to select from.

I'm thinking I need to implement usage of something like this (below) to wait for both the form to be open/accessible, for the drop-down box's handle to be accessible, and then maybe something else (which ISN'T included in the example code below) to verify that the drop-down box of SQL Server instances is finished being populated and a pre-selected value from that drop-down box that the application selects each time the form is opened is selected.  Only at THAT point when all 3 of those things have happened is it o.k. for my AutoIt script to proceed with clicking the "Connect" button on that form.

While (1)
     If $Waiting And WinExists("[CLASS:My3rdPartyApp]") Then
          $hCtrl = ControlGetHandle("[CLASS:My3rdPartyApp]", "", "MyDropDownBox")
               If $hCtrl Then
                    ; we got the handle, so the button is there
                    ; now do whatever you need to do
                    MsgBox(0, "Test", "Test")
                    $Waiting = False
               EndIf
     EndIf
WEnd
 
Many thanks for reading this and for any example code or hints you may have to let me know if the above code seems to be going generally in the right direction to accomplish this.
 
Thanks.

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