How can I effectively trace the execution of my script?

General Macro Scheduler discussion

Moderators: JRL, Dorian (MJT support)

Post Reply
SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

How can I effectively trace the execution of my script?

Post by SteenJakobsen » Thu Apr 22, 2010 7:05 am

Hi,

How can I effectively trace the execution of my script?

Can I have the Editor window positioned next to the app I’m automating (for example on monitor 2) and have the app constantly in focus (on monitor 1) while the script is executing step by step and by pressing some shortcut key then make the Script step 1 one line a time without the app loosing focus.

I have tried the debug mode using a **Breakpoint** but the switching of focus between the app an the MSEditor confuses the app as the
Loosefocus event is triggered, and also there are timing issues when focus is returned to the MSEditor before the automated app has received all keystrokes.

By having MSEditor on monitor 2 and the app in focus on monitor 1 and then being able to step through the script would be great.
The following debugging keys would be great:
1. Stop and Pause script (I can do that already.. :wink: )
2. Step 1 line at a time without the focus switching
3. Continue execution without single stepping until next breakpoint
4. Reenable single stepping so that a breakpoint is not needed.


Any feedback is mostly appreciated.
:D
Best Regards
Steen Jakobsen
DM Software A/S

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Fri Apr 23, 2010 6:02 pm

Hi SteenJakobsen,


I don't have a dual monitor setup so I am not sure if your request is possible. It may be that a dual monitor behaves in some ways like one doubly sized monitor.

I believe some of the problems you describe also occur with a single monitor. You can run the script from the editor in Trace mode from any point in the script without changing focus. However Trace mode ignores breakpoints so you probably would not be happy with that solution.

Macro Scheduler already has some capability to ignore itself. Perhaps this capability can be extended to breakpoint handling in an enhancement request.

In the meantime the best debugging method is to simply write to a logfile. You should be able to view it on the other monitor or even another computer. Search the forums for a "tail" script that always displays the most recent additions to the logfile. Of course you still don't have breakpoints.

Would it be acceptable if Macro Scheduler drew focus away from the application at breakpoints and then automatically put focus back on the application when you resume the script?



Gale

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Mon Apr 26, 2010 5:44 am

Hi Gale,

Thanks a lot for your reply.

The case is really simple and has nothing to do with 2 or 3 monitors.
Having 2 or 3 monitors just makes it simpler to handle many applications
as they can be maximized on individual monitors.
Having 2 applications aligned next to each other on one monitor gives the same scenario.

Basically what I’m asking is :
Using a shortcut key - can I step the script 1 line at a time and watch the script progressing and watch the variables in the watch list without MacroScheduler Editor pulling the focus away.

I can currently stop the scrip using “Shift+Escâ€
Best Regards
Steen Jakobsen
DM Software A/S

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

Post by Marcus Tettmar » Mon Apr 26, 2010 8:47 am

Hi,

Have you tried this:

1. Uncheck the option Debug/Refocus Windows. This will prevent the editor taking focus away.
2. Use Debug/Trace.

Now you will see the script progress one line at a time but focus will NOT be stolen.

Unfortunately this is not possible in conjunction with Step. Why? Because for Macro Scheduler to recognise that you have pressed the step key it must have the focus! We can't give the editor keyboard focus to accept a debug step request without taking focus away from the target application. Hence we offer the Debug/Refocus Windows option which remembers what had the focus before the step line and switches back to it when the user steps.

Another conundrum of debugging is that the very nature of debugging introduces a delay. With scripts that fail because they are running too fast and/or the developer has not made the script wait for events to complete/windows to be ready, the script will often work fine in debug mode, because of the inherent delay introduced.

So really the only way to analyse real time progress is to use logging. Of course you can only then view the log file after the script has run.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Mon Apr 26, 2010 9:02 am

Thanks Marcus,

I'll try to combine some subrutines and event statements and waitkeydown
I thinik I can create a nice concept.

You should realy se our implementation of the SDK in a couple of weeks :-)
Best Regards
Steen Jakobsen
DM Software A/S

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

Post by Marcus Tettmar » Mon Apr 26, 2010 1:24 pm

Steen,

Take a look at the latest v12 beta build. Trace can now be set to a zero second interval. If you do this with Refocus Windows off you should get pretty much what you want.

In actual fact to avoid possible lockups and to allow the user to still kill the session in case of tight loops etc, the interval is set to 0.2 seconds. Previously the lowest possible interval was 1 second and setting trace to zero did nothing.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Mon Apr 26, 2010 3:58 pm

mtettmar wrote:Another conundrum of debugging is that the very nature of debugging introduces a delay. With scripts that fail because they are running too fast and/or the developer has not made the script wait for events to complete/windows to be ready, the script will often work fine in debug mode, because of the inherent delay introduced.

So really the only way to analyse real time progress is to use logging. Of course you can only then view the log file after the script has run.
Note that even just turning on logging introduces additional delay as before, after or before and after execution of each line of a macro, it must write something to the logfile and that takes time. Not much time... but something... and that extra delay itself could make timing sensitive macros behave differently with logging on verses off.

Take care
Last edited by jpuziano on Tue Apr 27, 2010 4:31 pm, edited 1 time in total.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Tue Apr 27, 2010 10:29 am

Hi,


Thanks a lot :-)
Best Regards
Steen Jakobsen
DM Software A/S

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