Sign in to follow this  
Followers 0
AdamLeinss

WinWaitActive doesn't wait

7 posts in this topic

#1 ·  Posted (edited)

Greetings.

I have a problem with the following code. The problem is after CD2, the script does not wait with WinWaitActive and it seems to execute the rest of the script in one go (I've put a line of asteriks at the part of the script where it seems to break). I believe this is the case as I can hear a bunch of Windows sounds as if someone is hitting a bunch of keys. When it gets to CD3, the script just seems to have stopped.

I've tried inserting sleep commands before, after and before AND after WinWaitActive, but it doesn't matter. After the CD2, the script just sends the whole command stream to Pro/E. I commented out WinWaitActive and put in a hard coded sleep command of 300,000 ms (5 minutes) and that works. My

gut is telling me that because AutoIt has already seen the "Insert a new CD" window title, it just assumes it's still there and has cached it somewhere and executes the rest of the script.

I've worked on this for the past several hours and would love to have a fresh pair of eyes take a look. Thanks. ;)

Run ("\\wksms01\install\Windchill.PDM\ProE.Wildfire.4.0.M160.x86\Disk 1\setup.exe")
;Sleep(30000)
WinWaitActive("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)")
WinActivate("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)")
Send("!n")
Sleep(1)
Send("{SPACE}")
Sleep(1000)
Send("!a")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
ControlClick("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)","","[CLASS:Layout; INSTANCE:10]")
WinActivate("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)")
ControlClick("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)","","[CLASS:TextArea;INSTANCE:2]")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
Send("{SPACE}")
Send("{SPACE}")
Send("{SPACE}")
Send("{SPACE}")
WinWaitActive("Insert a new CD")
Send("{TAB}")
Send("{TAB}")
Send("{BACKSPACE}")
Send("2")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
; ********************************* SEEMS TO BREAK RIGHT HERE *****************************
Sleep (300000)
;WinWaitActive("Insert a new CD")
Send("{TAB}")
Send("{TAB}")
Send("{BACKSPACE}")
Send("3")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
Sleep (300000)
;WinWaitActive("Insert a new CD")
Send("{TAB}")
Send("{TAB}")
Send("{BACKSPACE}")
Send("4")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
Sleep (300000)
;WinWaitActive("Insert a new CD")
Send("{TAB}")
Send("{TAB}")
Send("{BACKSPACE}")
Send("5")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
WinWaitActive("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)")
WinActivate("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
Send("{SPACE}")
Edited by AdamLeinss

Share this post


Link to post
Share on other sites



My gut is telling me that because AutoIt has already seen the "Insert a new CD" window title, it just assumes it's still there and has cached it somewhere and executes the rest of the script.

No, AutoIt does a fresh check for a matching window about every 200msec for WinWaitActive(), each time it's called.

Can't speak to what your issue is since I can't run your script to test, but "cached" titles is not it.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

It's possible that the windows is not actually being closed, but rather just being hidden. Since it shouldn't be active if its hidden though, it really shouldn't make a difference. You might try reading the window handle each time you are waiting for an active window. If its always the same, then you're getting the same windows over and over. If it's different, then something else is going on.

You could also check to see if theres any text (visible or hidden) that you could use. Using titles alone usually isn't a good idea if you can help it.

Try this and see what comes up for the window handles:

Run ("\\wksms01\install\Windchill.PDM\ProE.Wildfire.4.0.M160.x86\Disk 1\setup.exe")
WinWaitActive("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)")
WinActivate("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)")
Send("!n")
Sleep(1)
Send("{SPACE}")
Sleep(1000)
Send("!a")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
ControlClick("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)","","[CLASS:Layout; INSTANCE:10]")
WinActivate("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)")
ControlClick("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)","","[CLASS:TextArea;INSTANCE:2]")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
Send("{SPACE}")
Send("{SPACE}")
Send("{SPACE}")
Send("{SPACE}")
$handle = WinWaitActive("Insert a new CD")
ConsoleWrite($handle)
Send("{TAB}")
Send("{TAB}")
Send("{BACKSPACE}")
Send("2")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
; ********************************* SEEMS TO BREAK RIGHT HERE *****************************
$handle = WinWaitActive("Insert a new CD")
ConsoleWrite($handle)
Send("{TAB}")
Send("{TAB}")
Send("{BACKSPACE}")
Send("3")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
$handle = WinWaitActive("Insert a new CD")
ConsoleWrite($handle)
Send("{TAB}")
Send("{TAB}")
Send("{BACKSPACE}")
Send("4")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
$handle = WinWaitActive("Insert a new CD")
ConsoleWrite($handle)
Send("{TAB}")
Send("{TAB}")
Send("{BACKSPACE}")
Send("5")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
WinWaitActive("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)")
WinActivate("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
Send("{SPACE}")

Share this post


Link to post
Share on other sites

It may be just a typo but in the original script posted the 2nd 3rd and 4th

WinWaitActive("Insert a new CD")

are commented out.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I tried the debug script above and when I hear the Windows event sounds, it's right after CD2 and I got this in the console window:

0x001A02460x001A02460x001A02460x001A0246

and the script ends having sent all the commands.

So somehow this window must be remaining in memory. If I do a WindowInfo on the window for CD 2 and CD 3, it's the exact same window. However, once you put in CD 2 or "2", the window goes away and the installation continues until a prompting for CD 3. Is there anything else I can do other than a sleep() command or WinWaitActive()?

P.S. Yes, WinWaitActive() was commented out above, because I could only get the installation to continue with sleep(). My problem with sleep is that some computers are fast and some are slow, so it's hard to predict a good time without testing each and every PC which I don't have the stomach for.

Edited by AdamLeinss

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Why not a combination of WinWaitClose and WinClose

or

If NOT Winactive (if you believe its just hiding), prior to continuing.

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

I fixed this by adding:

Sleep (5000)
WinActivate("PTC.Setup - Pro/ENGINEER Wildfire 4.0 (M160)")

before each WinWaitActive("Insert a new CD").

This re-focuses the back window and then when the insert a new CD window pops up, it grabs focus back and so forth.

Thanks for the brainstorming!

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