How to programmatically close a message box

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Heinz57
Junior Coder
Posts: 28
Joined: Wed Jul 22, 2015 6:10 pm
Location: A Berliner just east of Wien

How to programmatically close a message box

Post by Heinz57 » Tue Aug 04, 2015 10:00 pm

Hello,

my programming in MS works fine and I am implementing a sort of debug mode to give the operator / user frequent status information about what is going on besides writing this to a log file.

But when opening non-model MacroScheduler message boxes I find no way how I can close them again.

Is there something similar to IEClose related to MacroScheduler message boxes? I found nothing in the docs or in the forum.

The only way I could think of would be by via an image search and then pressing the button but that's kind of crazy and time consuming also.

Best regards
Heinz57

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

Re: How to programmatically close a message box

Post by Marcus Tettmar » Wed Aug 05, 2015 11:39 am

You can use CloseWindow:

CloseWindow>Macro Scheduler Message
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
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: How to programmatically close a message box

Post by JRL » Wed Aug 05, 2015 3:53 pm

I very often use message boxes for debugging and also just monitoring the progress of a completed script. I will often start a script with something similar to:

Code: Select all

Let>msg_xpos=10
Let>msg_ypos=10
Let>msg_width=500
Let>msg>height=300
Message>
Then as the code progresses, at points where I want to know certain variable values, I will use SetControlText> to put the information in the message box for display. For example:

Code: Select all

SetControlText>Macro Scheduler Message,TMemo,1,Cycle Count=%Cycle_Count%
You could just issue the Message> command over and over with different messages and visually get the same result. The reason to use SetControlText> is to prevent the message window from acquiring focus.

As Marcus pointed out you can programmatically close the message window using:

Code: Select all

CloseWindow>Macro Scheduler Message
Then reopen it at any time using:

Code: Select all

Message>

Heinz57
Junior Coder
Posts: 28
Joined: Wed Jul 22, 2015 6:10 pm
Location: A Berliner just east of Wien

Re: How to programmatically close a message box

Post by Heinz57 » Thu Aug 06, 2015 2:36 pm

@Mr. Tettmar

I beg your pardon but I forgot to mention in my OP that I hat tried CloseWindow>Macro Scheduler Message before and it did not work for me.

I now used it again only to find out that the exe aborts with an error when there is no such window. Since one can never be sure if the user has closed the message box, this is no solution.

I think the only proper solution would be to return a handle when creating a box very much like in IECreate. This handle could then be used to close the box and this operation should not crash if the window had been closed before.

@JRL
Thank you for this clever proposal. I will consider using it (later, currently busy with more urgent tasks). But I currently tend to delegate this to my main application, which will soon run as the master process and start MS scripts as needed. But this will only really work with the SDK.

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

Re: How to programmatically close a message box

Post by Marcus Tettmar » Tue Aug 11, 2015 1:46 pm

You could do:

Code: Select all

IfWindowOpen>Macro Scheduler Message
  CloseWindow>Macro Scheduler Message
Endif
This would only work for a NON modal message box of course.
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