Enhancement to Message command

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

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

Enhancement to Message command

Post by billtubbs » Fri Jan 26, 2007 12:47 am

Hi

I have a suggestion for the Message> command. Maybe there could be an option to use it in a way that the new message is added to the bottom of any existing message text, i.e. without closing the previous message window and opening a new one. This would be useful to create an on-screen log of macro progress (similar to the log file).

I wrote the following subroutine to achieve the same goal but it requires storage of all messages in an ever-increasing string and continual redisplay of the message window. See screenshot below.

Code: Select all

Let>ProgressLog=

SRT>ShowProgress

Sec>Seconds
Min>Minutes
Hour>Hour
ConCat>ProgressLog,%Hour%:%Minutes%:%Seconds% %ShowProgress_Var_1%%CRLF%
Message>ProgressLog

END>ShowProgress
Screenshot:
Image

With a new command such as MessageLog this code could be simplified to:

Code: Select all

Sec>Seconds
Min>Minutes
Hour>Hour
MessageLog>%Hour%:%Minutes%:%Seconds% Sim 2 complete%CRLF%

Bill.

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

Post by JRL » Fri Jan 26, 2007 11:08 pm

Bill,
If I'm understanding you correctly this can be nearly accomplished now using SetControlText>. You will still need to create the ever increasing string.

Your example would look something like this:


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


Here's a working sample that anyone can use. You'll notice that as info is added to the message, the time displayed at the top of the message box does not increment, proving that this is not merely another instance of a message box. It is the original message box being updated with additional information.

Code: Select all

Let>k=0
Let>text=Useless list
Let>MSG_CENTERED=1
Let>MSG_HEIGHT=400
message>%text%
Repeat>k
  Let>k=k+1
  Concat>text,%CRLF%%k%
  SetControlText>Macro Scheduler Message*,TMemo,1,%text%
  Wait>1
Until>k,20
mdl>%text%
You could also accomplish this same affect by setting up a dialog that you define. Something like:

Code: Select all

Dialog>Dialog1
   Caption=Progress Log
   Width=315
   Height=290
   Top=CENTER
   Left=CENTER
   Label=Progress Log,16,8
EndDialog>Dialog1

Show>dialog1
Let>ProgressLog=

Label>start
GetDialogAction>dialog1,r1
//do stuff
Gosub>ShowProgress
Wait>1
Goto>start

SRT>ShowProgress  
  Sec>Seconds
  Min>Minutes
  Hour>Hour
  ConCat>ProgressLog,%Hour%:%Minutes%:%Seconds% %ShowProgress_Var_1%%CRLF%
  Let>dialog1.mslabel0=%ProgressLog%
  END>ShowProgress
Hope this is helpful,
Dick

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

Post by Rain » Sat Jan 27, 2007 5:53 pm

Here is a short little script that will save your old message (in this example the time) and add the new message to the top.

Code: Select all

let>old_message=
label>loop
wait>1
gtm>new_message
msg>%new_message%%CRLF%%old_message%
let>old_message=%new_message%%CRLF%%old_message%
goto>loop

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

Post by billtubbs » Sat Jan 27, 2007 10:09 pm

Thanks Dick and Rain

You've solved the problem.

Rain, I like the way yours adds the new line to the top and thus solves the problem of the message window not automatically scrolling to the bottom of the message.

Bill.

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

Post by jpuziano » Sun Jan 28, 2007 6:27 am

billtubbs wrote:Rain, I like the way yours adds the new line to the top and thus solves the problem of the message window not automatically scrolling to the bottom of the message.
Yes, thanks again Rain for that.

However, if we need to show a Message Box where the newest log entries appear at the bottom and the latest entry is always visible as the mass of entries scrolls upward, how would we do this?

I know focusing the Message Box and sending keystokes to it is possible (arrow down, page down, CTRL-END, etc.) but that may be hit or miss depending on what else is happening on screen, how fast log entries are appearing, etc.

Marcus, would you consider adding "Auto-Scroll" as an enhancement to the Message> command? Sure would be nice for displaying a running log of events. It could be done with a new system variable for instance:
  • To make a message box automatically scroll to the bottom of its displayed text, set the variable MSG_AUTOSCROLL to 1. Default is 0.
Thanks again (JRL, Rain and others) for the great examples and script ideas.
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 - :-)

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

Post by Rain » Sun Jan 28, 2007 3:12 pm

Hi jpuziano,

This script is working pretty well on my system, even at a high rate of speed

Code: Select all

// Minimize all windows
Press LWinKey
Send>d
Release LWinKey
// This part is optional.
// I don't like the flickering of the scrollbar so I moved
// the message window off screen just enough to hide the scrollbar
GetScreenRes>X,Y
Sub>X,242
Let>MSG_XPOS=%X%
Let>MSG_YPOS=-25
Let>MSG_HEIGHT=200
Let>MSG_WIDTH=273
Let>old_message=
// Pressing the Tab key ensures the message area is in focus
Message>
Press Tab
Label>Log_loop
Wait>0.5
// Check if Message window is open, if Message window is open
// continue with the log loop, if closed go to end of script
// Note! If you plan on scrolling any faster than 0.5 sec use the
// Shift+esc key to shut the macro down or use OnEvent>KEY_DOWN,VK32,3,End_Loop
// if you don't want to shut the macro down (see help file for help with the OnEvent command)
ifw>Macro Scheduler Message,Message_Open,End
Label>Message_Open
GetTime>new_message
Message>%old_message%%CRLF%%new_message%
// Set message window in focus before sending the ctrl and end keys
SetFocus>Macro Scheduler Message
Press Ctrl
Press End
Release Ctrl
Let>old_message=%old_message%%CRLF%%new_message%
Goto>Log_loop
Label>End
I hope this helps

Rain

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