Jump to content

Can anyone figure out why WinExists isn't working in this script?


 Share

Recommended Posts

Hi all,

a co-worker and I are writing a script at work to make our lives easier, but a key part isn't working. It's supposed to check to see if a window exists, then write a line to a file based on if the window does or doesn't exist. But it's always writing the line for the doesn't exist scenario, even though it does exist! Neither one of us can see what's wrong. Hoping someone can help. Here's the problem code:

Run("d:\setup.exe")

Sleep (1000)

WinActivate ("The Print Shop 21 - Setup", "Welcome to the InstallShield Wizard for The Print Shop 21")

;dim $launch = WinExists ("The Print Shop 21 - Setup")

If WinExists ("The Print Shop 21 - Setup", "Welcome to the InstallShield Wizard for The Print Shop 21") Then

FileWrite ($results, "Setup launched" & @CRLF)

Else

FileWrite ($results, "Setup failed to launch" & @CRLF)

EndIf

I originally declared a variable for the WinExist statement, and then did the "if var=1 write launch, else write fail, blah, blah" but that didn't work either. That's when I switched it to how it is now. It always writes the "setup failed to launch" line. Thanks

Link to comment
Share on other sites

You can remove the 1 second sleep delay if you use WinWaitActive or WinWait instead of WinActivate.

That should make the script wait until the window is present before continuing... it will also let you know if you have the window title and text info correct.

Consider adding this line near the top of your script - if it is not there:

AutoItSetOption ("TrayIconDebug", 1)

Then mouse over the AutoIt icon in the system tray while the script is running. If the script hangs on the WinWait... line (while the window of interest is present), then check that line of code.

[size="1"][font="Arial"].[u].[/u][/font][/size]

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