Jump to content
Sign in to follow this  
gypsy

Help! WinWaitActive/WinActivate not always working

Recommended Posts

gypsy

I've had this program working in the past with no problems. Now, it seems that

WinWaitActive is not working some/most of the time. Program times out at WinWaitActive.

Here is a snipet of the code. Is there a better way to write this?

Help Appreciated!

$oWord = _WordCreate("C:\Documents\Test", 0, 1, 1)

If Not WinWait("Test", "Test", 120) Then

FileWriteLine($filelog, @error)

FileWriteLine($filelog, " Return Code - 0 WinWait() Timeout occurred")

Exit

EndIf

WinActivate("Test", "Test")

If Not WinWaitActive("Test", "Test", 120) Then

FileWriteLine($filelog, @error)

FileWriteLine($filelog, " Return Code - 0 WinWaitActive() Timeout occurred")

Exit

EndIf

$oDoc = _WordDocGetCollection($oWord, 0)

;Write some text

_WordDocSaveAs($oDoc, "C:\Documents\Test")

If Not WinClose("Test") Then

FileWriteLine($filelog, @error)

FileWriteLine($filelog, " Return Code - 0 WinClose() Window not found")

Exit

EndIf

Share this post


Link to post
Share on other sites
herewasplato

This worked for me 100 out of 100 times :-)

AutoItSetOption("WinWaitDelay", 1) ;(milliseconds)
AutoItSetOption("TrayIconDebug", 1) ;0-off

#include <Word.au3>

For $i = 1 To 100
    $oWord = _WordCreate("Test", 0, 1, 1)

    WinWait("Test", "Test", 120)
    WinActivate("Test", "Test")
    If WinWaitActive("Test", "Test", 120) = 0 Then
        MsgBox(0, "WinWaitActive", "Timed out on test number " & $i)
    EndIf

    Sleep(2000)
    _WordQuit($oWord)
    Sleep(2000)
Next
Xp Pro Sp2 - Office 2003

What OS and what Office version are you having this problem with?

Edited by herewasplato

[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  

×