Jump to content

Wait for window/button to become active using handle value?


Recommended Posts

I am very new to AutoIT and I have a program which I am trying to uninstall in a specific fashion. All of the window Titles are exactly the same including a popup window prompting for a restart.  My goal is to wait until the popup window is displayed so I can overwrite a value that was set in the registry before it restarts on its own.   When I use a command such as

;Wait & Click Next
WinWaitActive("ExampleProgram")
While Not ControlCommand('ExampleProgram','','Button1','IsEnabled','')
Sleep(1000)
WEnd
Run("ImportRegistry.bat")

The ImportRegistry.bat fires off immediately because the Title of all the windows are "ExampleProgram".  The only value that I have found unique to the popup window is the Handle Value.  So my question is, can I use the Handle Value instead of the Title Value to identify the window to wait for?  If not, is there another value or way to do this that is more feasible.  

 

Another issue is that based on how the program runs against a given computer it may or may not prompt for a restart, so if I implement the wait successfully, if the restart prompt window never appears will the script hang indefinitely?

Thanks for your patience and assistance in advance! :)

Link to comment
Share on other sites

I see that you're using controlcommand to check the state of the button and that is very good. What about the class of the program windows? Use the AutoIt info tool and look at the class, this can also be used inplace of the title. Read the helpfile listing "Window Titles and text" both the basic and the advanced in the AutoIt help file. That may give you some ideas to be more specific in your search.

Link to comment
Share on other sites

Ok, now I found this and got the desired result using the following code...

;Wait & Import Registry Then Click Ok
While 1    
$var = ControlGetText("[CLASS:#32770]", "", "Button1")
Sleep(1000)
If $var = "OK" Then
Run("ImportReg.bat")
Sleep(1000)
Send("{SPACE}")
ExitLoop
EndIf
WEnd

Now another question, if the popup window never appears, is there a way to have the wait timeout after a given amount of time so that the script can continue to a couple extra keystrokes? Thanks!

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...