Jump to content
Macro Express Forums

Macro Express Scripting Editor delay command


brianr-is

Recommended Posts

Is there a way to adjust the delay in a macro when looping through each record. For example the first record loop may take 300 seconds, the next record loop may take 30 seconds, the next record may take 60 seconds, etc. So, right now the macro I use has a delay of 300 seconds to accommodate the longest loop but, that applies to all record loops.

 

Brian.

Link to comment
Share on other sites

The answer is maybe. If there is a way, either indirectly or directly, to infer when a loop is done, you may be able to script it via Macro Express.

 

Things that you can look for as clues include:

 

1. The mouse cursor briefly changes shape when the process is complete.

 

2. Some object in the user interface changes colour when the process is complete.

 

3. Text appears in a field when the process is complete.

 

4. The text in a control changes when the process is complete.

 

If you provide more information about what happens when a loop is done, even if it is extremely subtle, write back, and hopefully the collective wisdom of this forum will be able to give you more ideas!

 

As an example, if text appears in an empty field to indicate the loop is done, you might be able to do something like this: clear the clipboard, move the cursor to the field, and then, every 5 seconds for 300 seconds, select the field and copy it to the clipboard. Test if the length of the clipboard text is greater than zero. If it is, then the field has been populated, and you are done. Otherwise, repeat 5 seconds later.

Link to comment
Share on other sites

Hi Alan,

 

Should I replace the delay at the end of the loop with a Wait for Text command?

 

Brian.

 

Insert a "Wait for Window Title" command at the end of the loop, so the script might look something like this:

 

<WAIT FOR WINDOW TITLE Title="Task is done!" Partial="FALSE" Wildcards="FALSE" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="300"/>

<TEXT TYPE Action="0" Text="<ENTER>"/>

 

You would need to set the title of the message box; I am assuming here that it is "Task is done!" The second line presses the Enter key, which in your case, may or may not activate the OK button. You will need to modify to make it work!

Link to comment
Share on other sites

Why do you have 300 seconds in the Window Title line? The amount of seconds varies with each record. Before, I only had the delay at 300 seconds to cover the longest running record loop.

 

300 seconds is the maximum time to wait. If the window appears earlier, no problem. But while waiting for it to appear, hands off the keyboard and mouse!

 

You may be able to avoid a macro that runs continually for up to 3 minutes per loop by scripting a second macro that gets activated when the window appears. If the message box has a unique title, this could be quite doable.

Link to comment
Share on other sites

Hi Alan,

 

Does this syntax look correct:

 

1st line: Wait for Window Title: "Title="End of Report." Partial="FALSE" Wildcards="FALSE" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="300"/>

2nd line: Text Type: Action="0" Text="<ENTER>"

 

It doesn't seem to work right now. I did notice that when doing the steps of the routine manually that pressing the Enter key after receiving the Window Title End of Report works just like clicking the OK button in the Window Title End of Report.

Link to comment
Share on other sites

Hi Alan,

 

Does this syntax look correct:

 

1st line: Wait for Window Title: "Title="End of Report." Partial="FALSE" Wildcards="FALSE" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="300"/>

2nd line: Text Type: Action="0" Text="<ENTER>"

 

 

Does the title really end in a period? End of Report. By any chance did you type in the title?

 

It's usually better to capture a title than type it.

 

  1. Ensure the End of Report message box is visible before proceeding.
     
  2. In your script, choose the "Wait for Window Title" command.
     
  3. Click the "Browse" button. You should find the window title on the list.
     
  4. Choose Partial or Exact match, and the maximum wait time.
     

 

If you don't see the message box listed, it may be a non-standard pop-up, in which case MEP cannot "see" it. You will need to resort to other techniques!

 

You may also need to insert a short time delay between the two statements.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...