Jump to content
Macro Express Forums

How to Capture Messages from the pop up Windows Application Message Boxes?


Recommended Posts

Well, if you do have a question we’re going to need more information than that if you want help.

 

Do you mean that you want to capture a particular type of message that does not allow copying to the clipboard?

 

If so, describe an example in detail or tell us exactly how we can reproduce  it. Show us some screenshots. Also, what script have you tried so far and what is the result? You can show your script commands and the resulting code using the Code tool, <>.

 

Terry

Link to comment
Share on other sites

I created macro that closing the claims. 10 % of all claims can't be closed because some additional steps have to be completed prior to closing. Pop up box let me know what has to be done for these 10% of all claims. How i can capture this situation? Planning to use MEP logic for the resolution. But I need to know how to capture the popup box and the message.

Link to comment
Share on other sites

During the early 2000s, Microsoft introduced a way to copy information from a message box to the clipboard.  For this method to work, the message box must have focus. But nothing needs to be selected.

 

In many (although not all) message boxes, pressing Ctrl + C copies its content to the clipboard as plain text. So the script might look like this.

 

Text Type (Simulate Keystrokes): <CONTROL>c
Variable Set String %x% from the clipboard contents
If Variable %x% Contains "Hello"
  MessageBox: Result True
Else
  MessageBox: Result False
End If

<TEXT TYPE Action="0" Text="<CONTROL>c"/>
<VARIABLE SET STRING Option="\x02" Destination="%x%" NoEmbeddedVars="FALSE"/>
<IF VARIABLE Variable="%x%" Condition="\x06" Value="Hello" IgnoreCase="FALSE"/>
<MESSAGEBOX Caption="Result True" Message="Contains \"Hello\"" Icon="0"/>
<ELSE/>
<MESSAGEBOX Caption="Result False" Message="Does not contain \"Hello\"" Icon="0"/>
<END IF/>
	

 

Link to comment
Share on other sites

14 hours ago, jso said:

I created macro that closing the claims. 10 % of all claims can't be closed because some additional steps have to be completed prior to closing. Pop up box let me know what has to be done for these 10% of all claims. How i can capture this situation? Planning to use MEP logic for the resolution. But I need to know how to capture the popup box and the message.

 

No screenshot or link as requested so I'll assume that you want to capture the text in pop-up boxes that do not allow the usual 'select then copy' approach.

 

If the text needs to be pasted elsewhere but does not necessarily have to be 100% accurate, investigate OCR using a third party tool.

 

If the text is brief and for your personal guidance after closing the message,  consider capturing its image and displaying it conveniently, or saving it in a reference folder.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
On 10/25/2019 at 1:16 PM, acantor said:

During the early 2000s, Microsoft introduced a way to copy information from a message box to the clipboard.  For this method to work, the message box must have focus. But nothing needs to be selected.

 

In many (although not all) message boxes, pressing Ctrl + C copies its content to the clipboard as plain text. So the script might look like this.

 


Text Type (Simulate Keystrokes): <CONTROL>c
Variable Set String %x% from the clipboard contents
If Variable %x% Contains "Hello"
  MessageBox: Result True
Else
  MessageBox: Result False
End If

<TEXT TYPE Action="0" Text="<CONTROL>c"/>
<VARIABLE SET STRING Option="\x02" Destination="%x%" NoEmbeddedVars="FALSE"/>
<IF VARIABLE Variable="%x%" Condition="\x06" Value="Hello" IgnoreCase="FALSE"/>
<MESSAGEBOX Caption="Result True" Message="Contains \"Hello\"" Icon="0"/>
<ELSE/>
<MESSAGEBOX Caption="Result False" Message="Does not contain \"Hello\"" Icon="0"/>
<END IF/>
	

 

 

My message takes several lines. How I can add 'RETURN' to %x%.Value?   Can I use LIKE to specify only part of the message?

 

Link to comment
Share on other sites

For Windows the value for 'RETURN' is actually a CR followed by LF. You can define variables to represent CR and LF:

Variable Set to ASCII Char 13 to %CR%
Variable Set to ASCII Char 10 to %LF%

Then you could use something like this:

If Variable %x% Contains "Hello%CR%%LF%There"

to search for

Hello
there

There are a couple of ways to search for parts of the message.

If Variable %x% Contains "Hello"
AND
If Variable %x% Contains "there"
  MessageBox: Result True
Else
  MessageBox: Result False
End If

Another way would be to parse the message using the Variable Modify String command options. (This is more involved so I do not provide an example here.)

Link to comment
Share on other sites

 

2 hours ago, jso said:

Can I use LIKE to specify only part of the message?

 

No, but Macro Express IF statements can test a variable to find  out whether it CONTAINS something:

 

If Variable %x% Contains "Hello!"

If Variable %x% Contains "Goodbye?"

If Variable %x% Contains "!"

If Variable %x% Contains "?"

If Variable %x% Contains "H"

If Variable %x% Contains "G"

If Variable %x% Contains " "  


So, if %x% = "Hello! Goodbye?" then all of the above statements will return TRUE.	
Link to comment
Share on other sites

There may be a workaround. The most elegant, if you can get it to work, is to capture the window control of the message. Maybe something like this will get you started. But you will probably need to do a lot of trial-and-error experimentation to get it to work, if it works!

 

Get Control: (ProgramName.EXE) Using z-order -> %x%
Get Control Class from %x% into %xClass%
Get Control Text from %x% into %xText%
Text Box Display: Class = %xClass%
Text Box Display: Text = %xText%

 

If the information you want is in xClass or xText, you may need instructions to parse it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...