Jump to content

Need help with WinWaitActive


EagleTG
 Share

Recommended Posts

I've been working with AutoIt for a while, but am still quite newbish compared to some of the AutoIt crazies on this forum.

Anyway, something I've never quite gotten the hang of is detecting when a WinWaitActive is going to wait forever. For example, I use AutoIt for a lot of installer-scripts (deployment of apps/programs, etc.). Every once in a while, there is a scenario within an installer that might create a "branch" in directions the install might take.

Perfect example is the RightFax v9.0 product installation. It auto-detects if .NET v1.1 is installed, if not, it installs it. The problem is that I need to have my script detect this point and branch-out accordingly. Here was my solution to that:

sleep(15000)
if WinActive("Microsoft .NET Framework") then
     WinWaitActive("Microsoft .NET Framework", "License Agreement")
     Send("!A!I")
     WinWaitActive("Microsoft .NET Framework", "Installation of Microsoft .NET")
     Send("{ENTER}")
EndIf

You'll notice the sleep(15000) at the top. This was to allow the RightFax installer time to figure out if it was going to launch the .NET install or not. My script waits the 15 seconds, then reads the window title to see if the RightFax installer launched the .NET installer, if not, it would follow through the rest of the installation.

I'd like a better way to do this, but haven't quite figured out how. I'd like the script to wait for the current window to change, then figure out (using an if statement, or whatever) which screen was displayed. The basic issue I'm having is detecting when the screen changes, but not knowing exactly WHAT the screen is going to change to. I guess I could just encapsulate each branch in a separate "if" statement, but was curious if anyone out there had any better suggestions?

Thanks, AutoIt is incredible!!!

Link to comment
Share on other sites

hi,

Does the RightFax Window change after detecting .net, or even after not detecting .net?

I've done a few Microsoft Windows updating scripts and found depending on the install (MS seems to never keep anything standard) I had to use WInWaitActive but also WinWaitNotActive, this may work to let you know one way or the other that it's continuing on from looking for .net.

Edit: in other words it may work if you Use WinWaitNotActive on the RightFax window that is displayed before/during the .net check, then when that window changes (is not Active) your script can continue.

Also really look at the text in the windows too even a small change maybe enough to help you detect and select it as a different window from before the .net checking.

Hope this helps a bit.

A.B.Ames

Edited by A.B.Ames
Link to comment
Share on other sites

  • Developers

I'd like a better way to do this, but haven't quite figured out how. I'd like the script to wait for the current window to change, then figure out (using an if statement, or whatever) which screen was displayed. The basic issue I'm having is detecting when the screen changes, but not knowing exactly WHAT the screen is going to change to. I guess I could just encapsulate each branch in a separate "if" statement, but was curious if anyone out there had any better suggestions?

You basically have 2 options here:

1. use AdlibEnable() which can handle any "Optional" window.

2. Use a While..Wend loop and test on the possible windows like:

; do you initial stuff here
While 1
    If WinExists("Optional Window1 Title","Optional text") then
       ; do what needs to be done for this optional window
    EndIf
    If WinExists("Optional Window2 Title","Optional text") then
       ; do what needs to be done for this optional window
    EndIf
    If WinExists("Next step Window Title","Optional text") then
       ; do what needs to be done for this window and exit loop
        ExitLoop
    EndIf
    Sleep(10)
Wend
; Logic for the next windows..

I also prefer to use WinExists() and then if needed WinActivate() because if for any reason the Window you are waiting for has lost the focus the WinWaitActive() will hang forever....

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

JdeB: That looks like exactly what I was after! Thanks a million!!!

A.B.Ames: I'll try that one too.

Thanks again guys!

Also you could write a routine that checks to see it .net is installed before you ever even start the installer for your program. That way you could know before hand if it needed to install it or not.

Link to comment
Share on other sites

Hi,

JdeB's got the best suggestions for running the script, as I do now remember (been a while) using similar (he's probably the one who helped me back then too). But I do remember having to use WinActive & WinNotActive, but using WinActivate (to make sure window had focus) prior to them because as he mentioned sometime focus is lost and it will hang. It's a pain as so many programs act differently during installs/updates.

I also think hankjrfan has a great idea too then you (as he said) kinda know what to expect.

TKAre

A.B.Ames

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