Jump to content
Macro Express Forums

Get Text from Active Window


sridharr

Recommended Posts

Hi All,

 

Through Macro Express, I have active another window (Title :Emulator).In the active window i need one string. i.e I need 3 row 5 column to 3 row 15 column. After that i need to assign this string to new string Variable.How can I do this?

 

 

Eg:

In VB

Dim a as string=application.gettext(3,5,3,15)

 

 

 

Thanks in Advance.

Link to comment
Share on other sites

If the window is an Excel window or similar, I would suggest having the macro open the GoTo feature and go to row 3 column 5. Then use the Text Type command to Shift and Arrow Right to highlight the 11 cells and copy the highlighted cells to the clipboard. Use the Variable Set String command and save the clipboard contents to a text string variable.

Link to comment
Share on other sites

If the window is an Excel window or similar, I would suggest having the macro open the GoTo feature and go to row 3 column 5. Then use the Text Type command to Shift and Arrow Right to highlight the 11 cells and copy the highlighted cells to the clipboard. Use the Variable Set String command and save the clipboard contents to a text string variable.

 

 

Nice Thinking. It is not an excel window. I am using mainframe window. Also this process takes time. If you have any other idea share with me.

Link to comment
Share on other sites

It is not an excel window. I am using mainframe window.

In that case you could try highlighting the entire window, copying it to the clipboard, copying from the clipboard to a variable and then parsing the result. The first three steps are pretty easy:

Text Type: <ALTD>a<ALTU>  // highlight everything in the window
Text Type: <CTRLD>c<CTRLU>  // copy to the clipboard
Variable Set String %T1% from Clipboard  // copy from the clipboard to a variable

This assumes that your terminal emulation software supports Ctrl-a to highlight everything. If not, you may need to experiment to see what works. Once you know how to do it manually you can implement it in a macro.

 

Parsing gets a little more involved. After running these commands T1 will likely contain a long string with CRLFs separating each line. You can use the various Variable commands to parse through the string to extract information from line 5, column 3. Macro Express Pro makes parsing this kind of information much easier due to the new Split String command.

Link to comment
Share on other sites

Hi All,

 

I need to copy 5 strings from emulator(Mainframe Window) .Please review my code.

 

My Code :

 

Variable Set String %T1% from Clipboard

Delay 2 Seconds

 

Variable Set String %T2% from Clipboard

Delay 2 Seconds

 

Variable Set String %T3% from Clipboard

Delay 2 Seconds

 

Variable Set String %T4% from Clipboard

Delay 2 Seconds

 

Variable Set String %T5% from Clipboard

Delay 2 Seconds

 

 

If delay is not given.Its not working as defined.So totally take 10 seconds delay+2 seconds for processing.

For Manual copy, It takes only 8 second.

Please improve my code ,if you have any idea.

Thanks

Sridhar R

Link to comment
Share on other sites

Can you copy everything from the clipboard to a variable and then parse through the variable? Then the delay would only be 2 seconds. And then you may be able to reduce the remaining delay down from 2 seconds.

 

 

Nice Idea. How to parse the text?

 

My Text :

 

 

· When changing the description ‘A’ to ‘T’ then Texas state exemption will be popped up.

· Some of the groups (ADP, Gevity) should not be processed.

· Match the renewal date with initial effective date

Ø Check the day and month for Open Enrollment.

Ø Check the day and month with the year for new group.

· State Exemption Pop up including the P& P to be referred.

· Time line for COBRA should be same for all the COBRA active dates.

· EA=N; Inquiry date should be the first of the insurance month for all process.

· In SGAR screen, Pop up should appear for the missing information or blank field in SGME.

· In SGAR the impacted employees list also popped up.

 

 

Parse any five text in the above Paragraph.

Link to comment
Share on other sites

Nice Idea. How to parse the text?

I'm sorry, I do not have time to write a complete macro right now. I can give you some hints, however.

 

You already know how to get the information to the clipboard and from the clipboard to a variable. The examples that follow assume the information from the entire screen is in T1. The next step is to 'parse' information one line at a time.

 

On some computers, each line is terminated with a CR (carriage Return) followed by a LF (line feed). On other systems lines may be terminated by LF alone or (in rare cases) CR alone. It is also possible that information from your screen will not be terminated by CR or LF but, instead, be grouped in lines of 25 (or 132, or whatever) characters. You will need to determine this for your system. The best way to make this determination is to write a macro and observe how it works. The following sample assumes each line is terminated by CRLF.

 

The first step of the parsing process is get CR and LF (CRLF) into a variable. This sample does just that:

Variable Set %T13% to ASCII Char of 13  // Set T13 to CR
Variable Set %T10% to ASCII Char of 10  // Set T10 to LF
Variable Set String %T13% "%T13%%T10%"  // Set T13 to CRLF

Then use something like this to find the first line:

Variable Set Integer %N1% from Position of Text in Variable %T1%  // Put %T13% (containing CRLF) into the Search Text field of this command
Variable Modify String: Copy Part of %T1% to %T2% // Save the result to N1

At this point T2 will contain the first line. Now, delete the first line from T1:

Variable Modify String: Delete Part of %T1%

And repeat the steps above. If you want to preserve each line then you will want to place the result in T3 instead of T2.

 

This should get you started. For more information study the variables documentation in the help. Good luck.

Link to comment
Share on other sites

I'm sorry, I do not have time to write a complete macro right now. I can give you some hints, however.

 

You already know how to get the information to the clipboard and from the clipboard to a variable. The examples that follow assume the information from the entire screen is in T1. The next step is to 'parse' information one line at a time.

 

On some computers, each line is terminated with a CR (carriage Return) followed by a LF (line feed). On other systems lines may be terminated by LF alone or (in rare cases) CR alone. It is also possible that information from your screen will not be terminated by CR or LF but, instead, be grouped in lines of 25 (or 132, or whatever) characters. You will need to determine this for your system. The best way to make this determination is to write a macro and observe how it works. The following sample assumes each line is terminated by CRLF.

 

The first step of the parsing process is get CR and LF (CRLF) into a variable. This sample does just that:

Variable Set %T13% to ASCII Char of 13  // Set T13 to CR
Variable Set %T10% to ASCII Char of 10  // Set T10 to LF
Variable Set String %T13% "%T13%%T10%"  // Set T13 to CRLF

Then use something like this to find the first line:

Variable Set Integer %N1% from Position of Text in Variable %T1%  // Put %T13% (containing CRLF) into the Search Text field of this command
Variable Modify String: Copy Part of %T1% to %T2% // Save the result to N1

At this point T2 will contain the first line. Now, delete the first line from T1:

Variable Modify String: Delete Part of %T1%

And repeat the steps above. If you want to preserve each line then you will want to place the result in T3 instead of T2.

 

This should get you started. For more information study the variables documentation in the help. Good luck.

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...
×
×
  • Create New...