brianr-is Posted November 30, 2010 Report Share Posted November 30, 2010 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. Quote Link to comment Share on other sites More sharing options...
acantor Posted November 30, 2010 Report Share Posted November 30, 2010 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. Quote Link to comment Share on other sites More sharing options...
brianr-is Posted November 30, 2010 Author Report Share Posted November 30, 2010 Hello Alan, At the end of each loop, I immediately get a text message box indicating End of report with an OK button that should be clicked. Brian. Quote Link to comment Share on other sites More sharing options...
brianr-is Posted November 30, 2010 Author Report Share Posted November 30, 2010 Hi Alan, Should I replace the delay at the end of the loop with a Wait for Text command? Brian. Quote Link to comment Share on other sites More sharing options...
acantor Posted November 30, 2010 Report Share Posted November 30, 2010 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! Quote Link to comment Share on other sites More sharing options...
brianr-is Posted December 1, 2010 Author Report Share Posted December 1, 2010 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. Quote Link to comment Share on other sites More sharing options...
acantor Posted December 1, 2010 Report Share Posted December 1, 2010 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. Quote Link to comment Share on other sites More sharing options...
brianr-is Posted December 1, 2010 Author Report Share Posted December 1, 2010 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. Quote Link to comment Share on other sites More sharing options...
acantor Posted December 1, 2010 Report Share Posted December 1, 2010 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. Ensure the End of Report message box is visible before proceeding. In your script, choose the "Wait for Window Title" command. Click the "Browse" button. You should find the window title on the list. 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. Quote Link to comment Share on other sites More sharing options...
acantor Posted December 1, 2010 Report Share Posted December 1, 2010 I just noticed that you are using Macro Express 3 rather than Macro Express Pro. The same principles apply, but you will probably need to start from scratch rather than using my code snippets. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.