creating a message box that times a macro being run

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
CZ
Newbie
Posts: 18
Joined: Wed Feb 07, 2007 7:51 am

creating a message box that times a macro being run

Post by CZ » Thu Feb 08, 2007 9:51 pm

I really appreciate the replies that I got on my last post. I was wondering if there was any way to create a message box on how long a macro that is currently running takes from start to finish. Also I thought that I had read something about a Delay function or code in the forum that refers to not having to continually write wait commands. Such as wait>1 ... wait>1, etc. I also believe that this other command was supposed to assist helping in preventing the macro from crashing or not working properly due to having the wait time being too short to allow certain parts of the macro to run. I hope I'm making sense. I can't remember where in the forum I saw it. I'd appreciate any help.

Thanks

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

Post by Marcus Tettmar » Thu Feb 08, 2007 10:52 pm

My preference is to use VBScript's Timer function which gives you seconds elapsed since midnight. Therefore the following can be used to tell you how many seconds the macro has taken from start to finish:

Code: Select all

VBSTART
VBEND

VBEval>Timer,timerStarted

.. do something
Wait>5

VBEval>Timer-%timerStarted%,timeElapsed
MessageModal>Seconds Elapsed: %timeElapsed%
Alternatively just enable Logging, or use the TimeStamp command and then read the log file into Excel or similar to analyse.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

CZ
Newbie
Posts: 18
Joined: Wed Feb 07, 2007 7:51 am

Post by CZ » Sat Feb 10, 2007 8:29 pm

Thanks for the help. Really appreciate it. It works great.

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Tue Feb 27, 2007 1:01 pm

Dumb question :oops:

How can I convert the result into dd/hh/mm/ss using VBEval?

Also, is there a way to pause the timer and restart it at the exact point it was paused?

Thanks,

Rain

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

Macro timer

Post by billtubbs » Thu Mar 15, 2007 8:44 pm

If you're interested I wrote a progress log/timer for my macro. Here is the code:

Code: Select all

Let>MSG_XPOS=25
Let>MSG_YPOS=100
Let>MSG_HEIGHT=240
Let>MSG_WIDTH=240
Let>MSG_STAYONTOP=1
Let>ProgressLog=
Message>ProgressLog

SRT>ShowProgress

Sec>Seconds
Min>Minutes
Hour>Hour
ConCat>ProgressLog,%Hour%:%Minutes%:%Seconds% %ShowProgress_Var_1%%CRLF%
SetControlText>Macro Scheduler Message*,TMemo,1,%ProgressLog%

END>ShowProgress

// Call this sub-routine in your code to 
// post progress to the message window:

GoSub>ShowProgress,Macro started
...
GoSub>ShowProgress,Macro finished

This subroutine opens a message window which stays in view. It is good for macros which take a long time. You can see progress and timing of all the steps in the macro. You can position the message window anywhere on the screen by changing the co-ordinates in the code.

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