Macro Scheduler stops processing

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
billtubbs
Junior Coder
Posts: 32
Joined: Thu Dec 07, 2006 10:00 pm
Location: Vancouver
Contact:

Macro Scheduler stops processing

Post by billtubbs » Thu Dec 07, 2006 10:11 pm

I'm trialling Macro Scheduler because I have an application that I need to automate.

However, this application is causing some problems for Macro Scheduler. I can navigate menus and press most buttons fine, until the application launches an APL workspace window to process some APL code (APL is an interpretive programming language).

At a certain point during the APL code I need Macroscheduler to press enter 6 times. My script successfully waits for the right moment then I use SetFocus to switch to the APL window. Unfortunately as soon as the focus switches to the APL window nothing happens. It is as if Macro Scheduler is no longer processing.

I am pretty sure that this APL window is hogging the processor or something, such that Macro Scheduler is not able to continue with the next command (If I press the enter keys manually and let APL finish, then right at the end MS finally does the required key presses, as if it had been temporarily suspended).

Anyone have any ideas?

I got around this problem earlier when I was using Visual Basic by using the application.ontime method to schedule an operation ahead of time. The scheduled event executes no problem and does the key presses in the APL window. Is there any way to schedule a task with the operating system in Macro Scheduler?

Bill.


Image
Last edited by billtubbs on Thu Dec 07, 2006 10:41 pm, edited 2 times in total.

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 » Thu Dec 07, 2006 10:34 pm

Hello Bill

We may be able to help solve your problem if we could see the code. Please provide a sample of the code where you think you are having the problem. Replace any confidential names/passwords with some dummy information.....

Macro Scheduler has a robust scheduling toolbox. Once a macro is created it can be set to run on many conditions. Go to the Macro Properties and the Scheduling tab to make your choices.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

billtubbs
Junior Coder
Posts: 32
Joined: Thu Dec 07, 2006 10:00 pm
Location: Vancouver
Contact:

Post by billtubbs » Fri Dec 08, 2006 6:31 pm

Thanks Bob

I'll check out the Macro Properties and the Scheduling tab. In the mean time here is the section of the macro code where it hangs up and also the associated log entries.

Looking at the log, you can see that Macro Scheduler goes into suspended animation when the 'SetFocus>APL*' command executes. The code only continues because I pressed the enter keys manually.

Bill.

Code: Select all

/Start simulation
Press Enter
Wait>16
/Switch to APL window
SetFocus>APL*
Wait>1
/Press enter 6 times to allow APL to Continue
Press Enter
Press Enter
Press Enter
Press Enter
Press Enter
Press Enter
/Wait for APL scipt to finish
Wait>16
/Close APL window
Press Enter
Send Character/Text>)off
Press Enter
Press Enter

Code: Select all

12/8/2006 10:33:08:046 - /Start simulation
12/8/2006 10:33:08:125 - Press Enter
12/8/2006 10:33:24:140 - Wait>16
12/8/2006 10:33:24:156 - /Switch to APL window
12/8/2006 10:34:27:906 - SetFocus>APL*
12/8/2006 10:34:29:000 - Wait>1
12/8/2006 10:34:29:046 - /Press enter 6 times to allow APL to Continue
12/8/2006 10:34:29:406 - Press Enter
12/8/2006 10:34:29:531 - Press Enter
12/8/2006 10:34:29:640 - Press Enter
12/8/2006 10:34:29:765 - Press Enter
12/8/2006 10:34:29:875 - Press Enter
12/8/2006 10:34:30:015 - Press Enter
12/8/2006 10:34:30:046 - /Wait for APL scipt to finish
12/8/2006 10:34:46:140 - Wait>16
12/8/2006 10:34:46:156 - /Close APL window
12/8/2006 10:34:46:171 - Press Enter

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 » Fri Dec 08, 2006 6:45 pm

The code and the log are very helpful....thanks....

I have a few thoughts here...

1. Your Task Manager shows another program Not Running. Is that the real problem, that CIMS has stopped running so Macro Scheduler is pressing Enter when the program is not ready to accept it?

2. What is the Enter clicking on? Should you use PushButton instead?

3. You may need to SetFocus again after the Wait>16. Maybe something else has stolen the focus?

4. Maybe use a WaitWindow/CheckFileExists, etc. type of function vs. Wait?

5. Do you need to do any type of Tab to position cursor before pressing Enter?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

billtubbs
Junior Coder
Posts: 32
Joined: Thu Dec 07, 2006 10:00 pm
Location: Vancouver
Contact:

Post by billtubbs » Fri Dec 08, 2006 7:12 pm

Bob

thanks for your ideas.

I don't think 2, 3 and 5 are the problem. I attach a view of the APL window just after Macro Scheduler has switched the focus to it. It is sitting there, with the cursor flashing, just waiting for those enters! (When I press enter manually they work fine so there is no problem with them).

Image

It might have something to do with the timing. I managed to get it to work just now by switching focus to the APL window earlier by clicking on it. Somehow that made the differences as the 6 enters were sent by MS on time. I'll investigate this more and I may not need to use the scheduler. Perhaps you're right that the CIMS application actually stalls the Macroscheduler so getting focus away from this earlier is essential.

The problem with the 'run when' scheduler is - will it work if Macro Scheduler is not responding? Also, I looked at the menu's and couldn't quite see how I could use it to schedule a macro 'in 15 seconds from now' kind of thing. And the trigger has to come in the macro code.

Bill.

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Fri Dec 08, 2006 7:15 pm

Some suggestions:

Start simulation
Press Enter
WaitWindowOpen>APL*
WaitReady>0

//not sure if you still need to wait 16 seconds or not...
Wait>16
/Switch to APL window
IfWindowOpen>APL*
SetFocus>APL*
else
mdl>APL window was not found
goto>End
endif
Wait>1
/Press enter 6 times to allow APL to Continue
//these ENTER's are blind in that they don't care if they are having any
// effect of not.

// sort of like feeding a tree into a mill even if the saw is broken.../

// you need come up with a way for each ENTER to check that it was successful
// before going on to the next
Press Enter
Press Enter
Press Enter
Press Enter
Press Enter
Press Enter
/Wait for APL scipt to finish
Wait>16
/Close APL window
Press Enter
Send Character/Text>)off
Press Enter
Press Enter
Label>End

billtubbs
Junior Coder
Posts: 32
Joined: Thu Dec 07, 2006 10:00 pm
Location: Vancouver
Contact:

Post by billtubbs » Fri Dec 08, 2006 8:44 pm

Thanks SkunkWorks

your suggestion of using WaitReady>0 was good. Much better than simple Wait commands. The script works now, but it's not entirely clear to me what did the trick.

As far as I can see adding an extra SetFocus>APL* as soon as the window was open was key. Then the WaitReady>0 command waits for the APL window to do its initial processing. A second SetFocus is required, and then the scipt successfully sends the enter keys. See log below.

thanks for the help everybody, I think Macro Scheduler will be very useful for my research.

Bill.

Code: Select all

12/8/2006 12:35:38:281 - /Start simulation
12/8/2006 12:35:38:421 - Press Enter
12/8/2006 12:35:39:140 - WaitWindowOpen>APL*
12/8/2006 12:35:39:875 - SetFocus>APL*
12/8/2006 12:35:39:906 - WaitReady>0
12/8/2006 12:35:50:218 - SetFocus>APL*
12/8/2006 12:35:51:343 - Wait>1
12/8/2006 12:35:51:375 - /Press enter 6 times to allow APL to Continue
12/8/2006 12:35:51:390 - Press Enter
12/8/2006 12:35:51:421 - Press Enter
12/8/2006 12:35:51:437 - Press Enter
12/8/2006 12:35:51:453 - Press Enter
12/8/2006 12:35:51:484 - Press Enter
12/8/2006 12:35:51:734 - Press Enter
12/8/2006 12:35:51:859 - /Wait for APL scipt to finish
12/8/2006 12:35:52:125 - WaitReady>0
12/8/2006 12:35:53:406 - Wait>1
12/8/2006 12:35:53:515 - /Close APL window

billtubbs
Junior Coder
Posts: 32
Joined: Thu Dec 07, 2006 10:00 pm
Location: Vancouver
Contact:

Problems again!

Post by billtubbs » Sat Nov 17, 2007 12:35 am

A year later I am still having problems automating this APL application! However, now that I have diagnosed the problem properly, perhaps someone can help me.

Diagnosis:
Once the APL processor reaches the point where the user prompt appears in the window, the program has the potential to hang-up all other programs (including macroscheduler) once focus is switched to it. This is evidenced by the attached screenshot in which the macroscheduler clock has stopped and its window is not refreshing (you can see I have wiped it into white by moving the APL window over it). Only if I manually add the key presses does macroscheduler go back into action.

Image

I can think of only two possible ways around this problem:
i) send the key presses to the window without giving it the focus
ii) fill the key queue with all the key presses, then switch focus in the hope that they all execute.

Anybody know how to do this or another way around the problem?

Bill.

Code: Select all

Wait>4
WaitWindowOpen>APL*
Wait>20
SetFocus>APL*

// Gets stuck on the above SetFocus command
// Focus visibly switches to the window but
// no further commands are executed
// (in the log the SetFocus command never completes)

// Press enter 6 times to contiue
Wait>0.5
Press Enter
Wait>0.5
Press Enter
Wait>0.5
Press Enter
Wait>0.5
Press Enter
Wait>0.5
Press Enter
Wait>0.5
Press Enter
Wait>0.5

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sat Nov 17, 2007 2:10 am

Is it possible you have multiple windows that match APL* ? Check view system windows, I've had problems in the past with non visible windows that match the wildcard SetFocus command confusing the program.

billtubbs
Junior Coder
Posts: 32
Joined: Thu Dec 07, 2006 10:00 pm
Location: Vancouver
Contact:

Post by billtubbs » Sat Nov 17, 2007 4:59 pm

Is it possible you have multiple windows that match APL* ?
No. APL* is the only window. The SetFocus command works in the sense that focus switches to the APL window. The problem is that at that instant all further macroscheduler commands stop until I manually respond to APL's user prompts. Basically, the APL program does not allow multi-tasking when it is waiting for user input.

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