bytegirl Posted October 13, 2005 Share Posted October 13, 2005 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 More sharing options...
herewasplato Posted October 13, 2005 Share Posted October 13, 2005 (edited) Try WinWaitActive instead of WinActivate. Edited October 13, 2005 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Developers Jos Posted October 13, 2005 Developers Share Posted October 13, 2005 Is the 1 second delay long enough to start the setup program and the window to appear ? 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 More sharing options...
herewasplato Posted October 13, 2005 Share Posted October 13, 2005 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now