How to use pause until to deal with a variable delay when the window name is unchanged

Hello,

I am writing a macro in the context of data entry in a third party application (the data entry is not a KB macro).

I want the macro to press the OK button (easy) after the user has completed all fields in the form and put the cursor in the first field of the next form.

My only problem is how to configure the pause between the OK button and the click mouse action to put the cursor in

Workflow: a window appears with fields to complete β†’ user completes fields β†’ presses OK button (press button action) β†’ delay of very variable duration which forces me to use long pause action (5 sec) β†’ next data entry window with identical name β†’ action (click) puts cursor in first field. β†’ user completes next form

I am looking for a way to substitute a pause until action to replace the long 5 sec pause. The actual delay is variable and lasts 0.2 to 5 sec.

I wanted to use pause until window name changes, but the window name is the same for each data entry.
Is there any variable which would allow me to pause until next blank data entry form appears ? Is there a window UUID ? is it possible to capture both the window name with the date and time, to make the window name unique ?

thank you in advance for your time and thoughts

I think you said, in the original thread, the user presses Return when switching from one page to the next. If so, that can be the trigger for KM to know the page is changed, rather than using a simple Pause statement.

I'm making a lot of inferences here, but I'm guessing that this code will wait a variable amount of time until the user presses the Return key.

This code will wait until the Return key is pressed, then wait until it is released, before allowing further KM code to run. (You don't need the Group action, but I like grouping a pair of actions like this.

This may or may not help you. I'm doing my best to help you without fully understanding what you are trying to do. I don't mind if you tell me that this won't work. Tell me why it won't work and I'll try to find a better solution.

1 Like

I am very grateful for your help
The problematic pause is between the time the return key is up and the window refreshes. It is this window refresh that it would like to identify or capture

I see. Well in that case we probably have to use Find Image to tell when the screen has refreshed. But since I don't have any screenshots of your screen before or after a refresh, there's no way for me to write a solution. Basically you will need to write a pause action that waits until a specific image appears on your screen. I think your best course of action is to practice using the Find Image action or the Find Image condition. Once you get the hang of it I think you will know how to detect a refreshed page. That's the best I can do without seeing your screens.

1 Like

I will try find image. Thanks again very much

1 Like

It would be most helpful (to you) if you could post:

  1. The name of the App you are using
  2. Screenshots of before the first form submittal (return) and then AFTER the next form is ready to enter.

Some Questions:

  1. Is the app scriptable?
  2. Is the structure of the second window/form different from the first?
  3. After you submit the first form, does the window stay in place, or is it replaced by another window?

What would be ideal, if the data is not sensitive, would be to do a video capture of the entire process, and tell us what you are doing as you do it. Seeing/hearing the whole process is the faster, best way to get you a solution.

if you have not seen this, it might be worthwhile:
Tip: How Do I Get The Best Answer in the Shortest Time?

2 Likes

Thank you very much for your reply as well as the link on how to better ask questions.
Unfortunately, it’s a specialized accounting app and I prefer not to display the information.
Although I take full responsibility for my poor wording of the question, I think that the issue is quite straightforward.
You have a data entry window with multiple fields which the user fills in then presses the OK button and another identical data entry window with the same name is displayed.
The problem is the variable delay between the time the OK button is released and the next data entry window is displayed. The variability of the delay forces me to systematically use a long five second pause.
My question is ; I would like to identify the instant between the time the OK button is released and the time the next data entry window is displayed in order to create a pause until action.
Thanks again very much for your time and help

Sure. Just use the Find Image action to "see" when the "next data window is displayed". You don't need to show us your application, but the Find Image action is very specific to each application, so then we can't help you create a macro that uses that solution.

A much better solution would be to take advantage of scriptability, but you didn't answer JM's three questions so I doubt he can help you with that better solution.

Things that may be obvious to you are not obvious to us. For example, you said "...the next data window is displayed". That could mean different things. We can't see it so it's hard to find the best solution.

That's fine, but just so you know, many image annotation/editing tools will allow you to blur selected parts of the image so that the data is not readable.

It is not that you weren't clear. The need for screenshots is save time and provide you with a better solution. There is often information that you don't notice that could be a key to the solution.

However, it would still be helpful if you could answer my questions:

2 Likes

I feel bad that this is taking so much of your time. I thought that the answer would be straightforward.

. definitely not scriptable
. structure is absolutely identical including the name
. it is replaced by another window as soon as the return key is up, BUT the delay to the appearance of the new identical in appearance and location window is very variable (0.2 sec to 5 sec). I thought that this would be the ideal trigger for pause until.

Please do not waste time on this issue. I thought that it would be simple straightforward.

thank again very much

I do this sort of thing all the time, using a different method than JM is trying to set up for you. I probably did it 20 times yesterday on my own computer, so I can handle many varieties of this type of problem. It's very easy using my method (albeit I have lots of experience doing it). All you do is issue a pause until a certain image is on the screen. Since I can't see your screen I can't write the code. The image needs to be indicative of when you have a new blank form. In some cases I can tell if a form is empty because a button changes its colour or its text, so I use that button as the indicator that I've reached a new record. In some cases I have to use an empty text field as my indicator.

Here is an example of one of those 20 pieces of code that I wrote yesterday that did pretty much what you are describing. Each one of my 20 pieces of code are a little different because the things I'm looking for on the screen are different in each case.

I've removed the actual images from the boxes for my own privacy. In this example I repeatedly sent a click to the window, (I repeat the click in case the window didn't receive the first click, which sometimes happens if my GUI is frozen) then I waited for ANY ONE OF TWO different images to appear on the screen. Sometimes it works that way, having to look for one of two, so I decided to upload that example for you here.

P.S. I don't consider helping you a waste of time, not at all. I've helped other strangers much longer than I've helped you, and I still come back for more. Your case is on the tricky side because you can't share your screens, and that's perfectly understandable.

I can't guarantee that my action above will be your solution, but I wanted you to get ideas about using Find Image conditions to "wait" until something occurs on the screen. If you start experimenting with code that works like this, I think you'll see how it can be used to solve your issue. I've never had a "wait for something on screen" problem that I couldn't solve, because if a human eye can tell when the screen is cleared, then so can KM. You just have to learn to describe in KM code what your human eye is doing.

1 Like

thank you very much for your reply and the illustration.
After reading your previous post where you mentioned found image, the only possibility I found was to to try to differentiate a field which was filled in from an empty field with no data.
I was the only solution I found and seemed like the ideal and obvious solution (thanks to your suggestion).
The problem is that Found Image has been in my experience more or less reliable. A kind of last resort.
In the case we are discussing for example, KBM found image does not appear to be able to differentiate:
image
from the same field but empty (not filled in), ie representing the 'next' form to complete.
thanks again very much for your help

I think this could be used with the pause until.
I don't have any app that behaves like what you describe, but this might work. Give it a try.

MACRO:   Pause Until Window Changes [Example]

**Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+**
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

#### DOWNLOAD Macro File:
<a class="attachment" href="/uploads/default/original/3X/9/1/919eca17765880a96b624dc5ba8e3b062fc10343.kmmacros">Pause Until Window Changes [Example].kmmacros</a>
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**




---



<img src="/uploads/default/original/3X/3/b/3b8b9ab338fcbdc86ef68b9373213ae2bdb4b1f2.png" width="502" height="972">
1 Like

Although Find Image can be unreliable, it can be quite reliable if you know what its limitations are. I think I've learned those limitations after using it for many years.

If I'm reading your example image correctly, I think it should be fine. The trick you may not realize is that to check if that field is empty you need to give Find Image some "assistance" by including part of the grey area around the image as part of its search image.

So here's the image that I would be searching for.

image

With those two different grey areas around the white empty box, I think Find Image will have no problems at all. Of course you have to take your own snapshot, not use the image I created above.

But there may be one more thing you need. You probably need to wait for that image to show (preferably in a certain small region on the screen where the name field is) and then wait for that image to NOT show which will indicate that the user has started typing again. That's a handy trick I use all the time.

1 Like

a very good idea. Thank you !

A brilliant solution. Works perfectly. Congratulations
It is elegant and exactly what I was trying for formulate in my question: some way of identifying a window change.
You are a genius !
Also a generic alternative to using pauses in all kinds of situations.
Your idea is really brilliant because pauses caused by variable delays can be a real problem in many situations.
At first it did not work. Now works with a minor correction: change in window name instead of exists.
To be used generically, the window name would have to be captured to a variable.

image

2 Likes

You are welcome.

It looks like JM's idea was even better. Good to hear. My ideas are not always the best ideas, even when they work.

I'm glad you thought about that. Great thinking! :+1:
Using this technique often requires that you tweak and fine-tune the conditions and actions until it works for your specific workflow.

1 Like