Jump to content

WinWaitActive Question


Recommended Posts

I am using an AutoIT script to login to my Enterprise software and run a program that runs anywhere from 1 to 1 1/2 hours. When the program is finished it asks a question. if the user desires to view a log file? I use the WinWaitActive at this point to wait for the window that asks the question. The next statment tabs to the no answer. I kick this off on a server using the Windows task scheduler. The problem is that the script frequently hangs at this point(WinWaitActive("Question")) which requires manual intervention to at least answer the question. Am I not incroporating the WinWaitActive properly? Is there another function I should be using? Thanks.

Code Example:

WinWaitActive("Process MRP")

send("{RIGHT}{TAB 3}")

sleep(1000)

send("MRPLog" & $logfiledate)

sleep(2500)

send("{TAB}{ENTER}")

WinWaitActive("Question")

send("{TAB}{ENTER}")

WinWaitActive("Information")

send("{ENTER}")

sleep(1000)

Send ("!{F4}")

WinWaitActive("Vantage")

Send("{TAB}{ENTER}")

Link to comment
Share on other sites

You should check to make sure WinActive is not activate then WinActivate it. Then you can WinWaitActive or WinWait

You are suggesting that I insert something like the following prior to the WinWaitActive("Question")?

If WinActive("Question") = 0 Then

WinActivate("Question")

EndIf

Link to comment
Share on other sites

A simple UDF function to handle the activation of the windows and then put underscores in front of the WinWaitActive functions and it may perform better.

_WinWaitActive("Process MRP")
send("{RIGHT}{TAB 3}")
sleep(1000)
send("MRPLog" & $logfiledate)
sleep(2500)
send("{TAB}{ENTER}")
_WinWaitActive("Question")
send("{TAB}{ENTER}")
_WinWaitActive("Information")
send("{ENTER}")
sleep(1000)
Send ("!{F4}")
_WinWaitActive("Vantage")
Send("{TAB}{ENTER}") 


Func _WinWaitActive($title, $text = "")
    ; wait for window, activate it and
    ; then wait until it is active
    WinWait($title, $text)
    WinActivate($title, $text)
    WinWaitActive($title, $text)
EndFunc

:)

Link to comment
Share on other sites

A simple UDF function to handle the activation of the windows and then put underscores in front of the WinWaitActive functions and it may perform better.

CODE SAMPLE REMOVED

:)

That's exactly what I do in my scripts that use WinWaitActive :P guess I should have suggested that.

Link to comment
Share on other sites

A simple UDF function to handle the activation of the windows and then put underscores in front of the WinWaitActive functions and it may perform better.

_WinWaitActive("Process MRP")
send("{RIGHT}{TAB 3}")
sleep(1000)
send("MRPLog" & $logfiledate)
sleep(2500)
send("{TAB}{ENTER}")
_WinWaitActive("Question")
send("{TAB}{ENTER}")
_WinWaitActive("Information")
send("{ENTER}")
sleep(1000)
Send ("!{F4}")
_WinWaitActive("Vantage")
Send("{TAB}{ENTER}") 


Thanks much. This seems to work.

Func _WinWaitActive($title, $text = "")
    ; wait for window, activate it and
    ; then wait until it is active
    WinWait($title, $text)
    WinActivate($title, $text)
    WinWaitActive($title, $text)
EndFunc

:)

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