Jump to content

Wait window respond


Recommended Posts

Hi everybody,

I'm doing a automation to a program that uses the "send" command to do some tasks in a specific window. These tasks will be processed in variable time.

My problem is: I need pause my script until the window responds to continue my script.

I tried winwait and winwaitactive commands, but the window exists and is active, and autoit doesn't pauses my script.

How can I do this?

Thanks

Paulo.

Link to comment
Share on other sites

Welcome to the forum.

Is there any part of the window that changes when the application is ready for the script to continue? Maybe some text or a button/control that becomes "enabled" - like "Next".

If some window text changes, use that in a WinWait line

WinWait("title", "text")

If a button/control that becomes "enabled", maybe

Do

Sleep(100)

Until ControlCommand("title", "text", controlID, "IsEnabled", "")

-MSP-

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

Link to comment
Share on other sites

Hi herewasplato,

Thanks for your quick reply,

Nothing changes in the window when the application is ready. The only diference is that when I click in the OK button, the window is closed.

I tried the following script that works, but the window "pop up" in the screen every 3 seconds

$a = 1

While $a = 1

If WinExists("Links of document") Then

WinActivate("Links of document")

Send("{TAB}{TAB}{TAB}{TAB}{ENTER}") ;find and press the ok button

Else

$a = 0

EndIf

Sleep(3000)

WEnd

Link to comment
Share on other sites

...Nothing changes in the window when the application is ready...

Is the "OK button" greyed out for a while? If not then a human user would have to just keep clicking like your script does - the human would have no indication that the app was ready for interaction.

If the "OK button" greyed out for a while, then you might be able to use the

ControlCommand("title", "text", controlID, "IsEnabled", "")

line that I mentioned above.

Anyway, here is another way to do what you coded.

WinWait("Links of document")
Do
    Sleep(3000)
    WinActivate("Links of document")
    Send("{TAB 4}{ENTER}") ;find and press the ok button
Until Not WinExists("Links of document")
You might want to replace the Send line with a ControlSend or ControlClick.

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

Link to comment
Share on other sites

Is the "OK button" greyed out for a while? If not then a human user would have to just keep clicking like your script does - the human would have no indication that the app was ready for interaction.

If the "OK button" greyed out for a while, then you might be able to use the

ControlCommand("title", "text", controlID, "IsEnabled", "")

line that I mentioned above.

Anyway, here is another way to do what you coded.

WinWait("Links of document")
Do
    Sleep(3000)
    WinActivate("Links of document")
    Send("{TAB 4}{ENTER}") ;find and press the ok button
Until Not WinExists("Links of document")
You might want to replace the Send line with a ControlSend or ControlClick.
One other thought (and one that I've been using in a recent script), is that the change can be as subtle as a change in the highlighting or border of a control (e.g. focus switches to OK button), and if there is such a change, you can test for it with Pixelchecksum, passing pixelchecksum the window coordinates or the coordinates of a single control on the window.
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...