OnEvent for Macro Scheduler Errors

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Simon_Slater
Newbie
Posts: 7
Joined: Thu Oct 16, 2008 4:43 pm

OnEvent for Macro Scheduler Errors

Post by Simon_Slater » Mon Nov 03, 2008 1:19 pm

I’m looking for a way to use OnEvent to branch my script when a Marco Scheduler error occurs i.e. when a window fails to open and the script has a Set Focus statement for that window.

It appears that the error will stop the script instantly and the MS error message appears, thus stopping the OnEvent function from picking up the error. I don’t want to use the IGNOREERRORS setting, as this may result in my script sending text into the wrong screen. The script is being used to reconfigure an application and this could result in the wrong information being sent.

Does anybody have any ideas on something else I could try?

Thanks


Simon.

User avatar
JRL
Automation Wizard
Posts: 3505
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Nov 03, 2008 2:10 pm

What I would do would be put a File_exists Onevent in the primary script and put a Window_Open OnEvent in a dynamically created secondary script. See this thread for an example of creating a secondary script. The second script would first create the file specified in the File_Exists OnEvent then it would pick the "Ignor" in the SetFocus Warning window so that the Primary script can proceed. Since the primary script has a File_exists Onevent and the file now exists, you can branch to whatever needs to be done. Don't forget to delete the file.

Hope this makes sense.
Dick

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

Post by Marcus Tettmar » Mon Nov 03, 2008 2:30 pm

To prevent a SetFocus error you should use IfWindowOpen first. I.e. YOU can make the script check if the window is open or not and what to do in each case. If you code the script like that you shouldn't get any SetFocus errors because you've already checked if the window is open.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Simon_Slater
Newbie
Posts: 7
Joined: Thu Oct 16, 2008 4:43 pm

Post by Simon_Slater » Mon Nov 03, 2008 4:19 pm

Dick - I might be able to do something around what you're suggesting, I'll have to have a bit of a think about it. Thanks for the input.

Marcus - I'm already using the IfW command, in parts of the script, but this is a bit of a strange app in that it seems to cache some window details and reports that the window is there, when it isn't (visible or hidden, and it has lots of hidden windows with the same name or very similar names - thank godness for wf_type) and occasionally I can see the window but MS doesn't. Also the App seems to report the window is ready for input (wrd>1) but the window isn't even open yet!!

You might remember this app, as we spent quite a lot of time trying to get the MS to read the text off of the screen and I eventually found that I had to set focus to another window (i.e. a very small notepad window, that the script opens) so that MS could capture the text from the original window!!

Some of this is speed related so I have been using lots of dynamic delaying tactics such as changing the step_delay or the sk_delay or using WRD and WCC etc.

I wanted to use the OnEvent command as a bit of a catch all and thought this might be the best place to get some ideas on this or alternatives.

Cheers


Simon.

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

Post by Marcus Tettmar » Mon Nov 03, 2008 4:45 pm

Well, as Dick suggests, you could use OnEvent in a second macro, so you have two processes. Therefore the OnEvent macro is not held up by the first (which gets held up by the error messages) and the second OnEvent one can process the messages.

Just so happens I wrote about this recently:
http://www.mjtnet.com/blog/2008/10/31/a ... processes/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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