Sign in to follow this  
Followers 0
bytegirl

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

4 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try WinWaitActive instead of WinActivate.

Edited by herewasplato

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

Share this post


Link to post
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]

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