WaitReady command

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

WaitReady command

Post by Bob Hansen » Tue Apr 10, 2007 4:56 pm

From the Help:
WaitReady suspends script execution until the foreground window has finished processing mouse, keyboard, show window, and optionally, paint events. Issue 1 to include paint events, and 0 to exclude paint events. This command can therefore be used to wait until the active application is ready to receive keyboard and mouse events in most situations.
I have been using this for years, and thought that I understood it. But some recent scripts have been causing me some problems, and I thought I would use this again, but am not having the success I expected.

Could you please provide a more detailed explanation of the differences, and perhaps a longer list of what might constitute painting activities? The operative words in the Help section may be "most situations"

I am also finding that if I Single Step through a script that has WaitReady>1, that I cannot proceed because it will never be ready? Is that normal? If yes, can we have a way to step over that command in the Single Step Mode?

My current problem is specifically when doing muliple Search/Replace tasks in TextPad. I open the Replace window, Send in the Search string, Tab, Send in the Replace string, do Replace all. I am then using WaitReady> to wait for completion before the loop continues for next Search/Replace. At this time I will probably change to WaitRectChanged or other image process. But I really expected that WaitReady would do this for me.

Thanks for listening.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Aaron
Pro Scripter
Posts: 113
Joined: Mon Apr 09, 2007 1:35 am
Location: Wyoming

WaitCursorChanged

Post by Aaron » Tue Apr 10, 2007 5:33 pm

would the WaitCursorChanged work?

This command is useful for waiting for applications to become idle. For example, it can be used after initiating some operation in an application that invokes the hourglass cursor, so that you can wait for the application to become idle again.
Aaron

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Apr 10, 2007 5:44 pm

Thanks for suggestion Aaron, but will not work in this case.

Am not controlling cursor movement, using keyboard movements, cursor may actually be outside the window with focus.

There are a number ways to control the waiting process, but I am really wanting an more thorough explanation of what WaitReady is doing and when it is best to use it. I have used this in the past with success (I thought), but am now wondering if I have misunderstood, and should possibly change it in some earlier scripts. This particular Search/Replace has a much longer delay needed than I have needed in the past, and it is possible that it might not work properly in the future on existing scripts. Maybe it is not working working, and I have been fooled.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Apr 10, 2007 5:44 pm

>Could you please provide a more detailed explanation of the
>differences, and perhaps a longer list of what might
>constitute painting activities?

WaitReady>0 waits for keyboard and mouse messages to finish being processed as well as show_window menu select messages. WaitReady>1 additionally waits for WM_PAINT messages to cease being processed.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Apr 11, 2007 4:05 am

Bob, WaitKey isn't reliable as you would expect from the command definition. The commnad isn't faulty but its performance or, to be exact, its nonperformance depends on other external factors such as delays caused by the busy hard drive access, busy internet server access,...etc.

Instead I prefer GetRectChecksum to obtain the checksum of a tiny "definitive reference" area, such as "Done" and "Ready". It's absolutely more reliable in a sense that your script always runs as expected. A word of caution, GetRectChecksum is slow. Please don't attempt a large area.
Example:
Wait>.2
GetRectChecksum>5,590,15,600,CS
If>CSStop
Label>Stop
Hope you find it useful.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts