Jump to content
Macro Express Forums

Parsing


MEnewb1143
 Share

Recommended Posts

I know this has been asked many times, and I've searched the forums quite a bit.

 

I know it's possible.. My goal is to get an email, based on that, run a macro. I need to copy the whole email to the clipboard(I think) and then parse out what I need. What I need is a number, so among text, that's easy. The macro needs to switch to another application(SecureCRT) use a command and inset that number in the middle of that command. Got that part. I need to copy only a piece of what pulls up from all the information. I can't tab or up arrow, but I can use my mouse to select the type. I would like to search the window for the starting few words(which don't change) and the last few words(which don't change) and select everything in between rather than the mouse coords since windows sometimes move and the response is sometime shorter of longer. Then I need to paste that into an email. They copying and pasting and switching windows I've got. It's the selecting the type of the email(that one number) and from the SecureCRT window that stumps me. Long drawn out explanation, but I wanted to be as clear as I could. :) I'm a newb(check the user name :) ), so just saying that I need to copy to the clipboard, save to a variable and parse it doesn't make much sense. My ripping apart the forums gave me that! :)

 

Any help would be greatly appreciated.

 

Thanks

Link to comment
Share on other sites

Welcome to the forum.

 

Since you know the text at the beginning and the text at the end and since the size of the window varies, my recommendation is to ... (yes) ... highlight the text, copy it to the clipboard, copy the clipboard to a variable, and parse the variable. I will outline how this works but you may need to spend a few minutes in the help file for details.

 

Highlight the Text

The first thing to think about when trying to accomplish something with Macro Express is "How would I do that manually". Many Windows programs will allow you to highlight the content of a window by pressing Ctrl-a. So, when the email is visible, does Ctrl-a highlight everything? If so, then this step is easy. Just Text Type: <CTRLD>a<CTRLU>. (Note that you should use lowercase letters not uppercase. If you use uppercase A you are actually sending <CTRLD><SHIFTD>a<SHIFTU><CTRLU> which may not work in some applications.)

 

If <CTRLD>a<CTRLU> doesn't work you might want to try typing the keystrokes that 'forward' the email message. Then the body of the email will be in an editable box and the Ctrl-a technique is likely to work. After the text is highlighted and copied to the clipboard you could type <ESC> or something similar to cancel the forward of the email.

 

If this does not work then you need to find another way to highlight everything. Perhaps using the mouse will help. Again, experiment manually to determine what will work for your application. You may be able to click the mouse button down and drag it to another location. If that is the case you will need to know where to start and where to stop.

 

There are macro commands to return the position (relative to the screen) of a window. Look at the Variable Set Integer %N1% from Top of Window, Variable Set Integer %N2% from Left of Window, Variable Set Integer %N3% from Width of Window and Variable Set Integer %N4% from Height of Window commands. Once you know the coordinates of the Window it becomes a math problem to determine the position of the area within the program window that actually contains the information you need. You may need to adjust the top coordinate, for example, to skip over menus, toolbars and headers. The Variable Modify Integer command allows you to do math.

 

You need to find top-left and bottom-right positions of the window containing the body of the email. Each of these positions require two variables (for the top and left or the bottom and right) for the X and Y coordinates. Once you have the two locations you can move the mouse to the beginning, do a Mouse Left Button Down then move the mouse to the ending position Mouse Move Screen %N3%, %N4% and then do a Mouse Left Button Up to highlight the text.

 

And one more option would be to use the Window Control commands. If they work they would greatly simplify finding the position of the area of the window containing the body of the email message.

 

Copy to Clipboard

Use the Text Type: <CTRLD>c<CTRLU> command to copy to the clipboard. You could also use Text Type: <CONTROL>c or Clipboard Copy. There are several ways to copy to the clipboard because some methods work with some programs and not others.

 

You will likely need a small amount of delay between highlighting and copying to the clipboard. Macro Express sends commands very quickly and Windows often needs a chance to finish one command before the next one is sent.

 

Parse the variable

This step is also straight forward. Use the Variable Set Integer %N1% from Position of Text in Variable %T1% command to find the location of the 'beginning' text in the variable. Use the Variable Set Integer %N2% from Position of Text in Variable %T1% command again to find the location of the 'ending' text in the variable. Then, using the Variable Modify String: Copy Part of %T1% to %T2% command you can copy the information between the beginning and the end. You will need to adjust the beginning variable (in this case %N1%) to take into account the length of the 'beginning' text string.

 

The resulting macro may look something like this:

// Highlight
Text Type: <CTRLD>a<CTRLU>
Delay 0.1 Seconds

// Copy to clipboard
Text Type: <CTRLD>c<CTRLU>
Delay 0.1 Seconds

// Copy from the Clipboard to a Variable
Variable Set String %T1% from Clipboard

// Parse the variable
Variable Set Integer %N1% from Position of Text in Variable %T1%
Variable Set Integer %N2% from Position of Text in Variable %T1%
Variable Modify String: Copy Part of %T1% to %T2%

 

If you do not want to tackle the problem that way you could, as you describe, try to find the beginning text and the ending text and copy only the information in between. The trick would be to know how to determine where the beginning and ending text are located. So, how would you do this manually? See if there is a command in your email client that allows you to do a 'Find'. In Outlook you press the F3 key to start a find so you would do a Text Type: <F3> command. I would find the beginning text and store that position in two variables (for the top and left or, in other words, the X and Y coordinates) and then find the ending text and store that position in two other variables. Once you have the two locations you can move the mouse to the beginning, do a Mouse Left Button Down then move the mouse to the ending position Mouse Move Screen %N3%, %N4% and then do a Mouse Left Button Up.

 

 

The reason other topics suggest copying the entire thing to the clipboard (the first technique described above) is because that method is likely to be more reliable and probably quicker.

 

Best of luck to you. We are here to help if you get stuck.

Link to comment
Share on other sites

Welcome to the forum.

 

Since you know the text at the beginning and the text at the end and since the size of the window varies, my recommendation is to ... (yes) ... highlight the text, copy it to the clipboard, copy the clipboard to a variable, and parse the variable. I will outline how this works but you may need to spend a few minutes in the help file for details.

 

Highlight the Text

The first thing to think about when trying to accomplish something with Macro Express is "How would I do that manually". Many Windows programs will allow you to highlight the content of a window by pressing Ctrl-a. So, when the email is visible, does Ctrl-a highlight everything? If so, then this step is easy. Just Text Type: <CTRLD>a<CTRLU>. (Note that you should use lowercase letters not uppercase. If you use uppercase A you are actually sending <CTRLD><SHIFTD>a<SHIFTU><CTRLU> which may not work in some applications.)

 

If <CTRLD>a<CTRLU> doesn't work you might want to try typing the keystrokes that 'forward' the email message. Then the body of the email will be in an editable box and the Ctrl-a technique is likely to work. After the text is highlighted and copied to the clipboard you could type <ESC> or something similar to cancel the forward of the email.

 

If this does not work then you need to find another way to highlight everything. Perhaps using the mouse will help. Again, experiment manually to determine what will work for your application. You may be able to click the mouse button down and drag it to another location. If that is the case you will need to know where to start and where to stop.

 

There are macro commands to return the position (relative to the screen) of a window. Look at the Variable Set Integer %N1% from Top of Window, Variable Set Integer %N2% from Left of Window, Variable Set Integer %N3% from Width of Window and Variable Set Integer %N4% from Height of Window commands. Once you know the coordinates of the Window it becomes a math problem to determine the position of the area within the program window that actually contains the information you need. You may need to adjust the top coordinate, for example, to skip over menus, toolbars and headers. The Variable Modify Integer command allows you to do math.

 

You need to find top-left and bottom-right positions of the window containing the body of the email. Each of these positions require two variables (for the top and left or the bottom and right) for the X and Y coordinates. Once you have the two locations you can move the mouse to the beginning, do a Mouse Left Button Down then move the mouse to the ending position Mouse Move Screen %N3%, %N4% and then do a Mouse Left Button Up to highlight the text.

 

And one more option would be to use the Window Control commands. If they work they would greatly simplify finding the position of the area of the window containing the body of the email message.

 

Copy to Clipboard

Use the Text Type: <CTRLD>c<CTRLU> command to copy to the clipboard. You could also use Text Type: <CONTROL>c or Clipboard Copy. There are several ways to copy to the clipboard because some methods work with some programs and not others.

 

You will likely need a small amount of delay between highlighting and copying to the clipboard. Macro Express sends commands very quickly and Windows often needs a chance to finish one command before the next one is sent.

 

Parse the variable

This step is also straight forward. Use the Variable Set Integer %N1% from Position of Text in Variable %T1% command to find the location of the 'beginning' text in the variable. Use the Variable Set Integer %N2% from Position of Text in Variable %T1% command again to find the location of the 'ending' text in the variable. Then, using the Variable Modify String: Copy Part of %T1% to %T2% command you can copy the information between the beginning and the end. You will need to adjust the beginning variable (in this case %N1%) to take into account the length of the 'beginning' text string.

 

The resulting macro may look something like this:

// Highlight
Text Type: <CTRLD>a<CTRLU>
Delay 0.1 Seconds

// Copy to clipboard
Text Type: <CTRLD>c<CTRLU>
Delay 0.1 Seconds

// Copy from the Clipboard to a Variable
Variable Set String %T1% from Clipboard

// Parse the variable
Variable Set Integer %N1% from Position of Text in Variable %T1%
Variable Set Integer %N2% from Position of Text in Variable %T1%
Variable Modify String: Copy Part of %T1% to %T2%

 

If you do not want to tackle the problem that way you could, as you describe, try to find the beginning text and the ending text and copy only the information in between. The trick would be to know how to determine where the beginning and ending text are located. So, how would you do this manually? See if there is a command in your email client that allows you to do a 'Find'. In Outlook you press the F3 key to start a find so you would do a Text Type: <F3> command. I would find the beginning text and store that position in two variables (for the top and left or, in other words, the X and Y coordinates) and then find the ending text and store that position in two other variables. Once you have the two locations you can move the mouse to the beginning, do a Mouse Left Button Down then move the mouse to the ending position Mouse Move Screen %N3%, %N4% and then do a Mouse Left Button Up.

 

 

The reason other topics suggest copying the entire thing to the clipboard (the first technique described above) is because that method is likely to be more reliable and probably quicker.

 

Best of luck to you. We are here to help if you get stuck.

I'm getting there, honestly! :) F3 does nothing for me, not sure why. But that's not entirely a bad thing. Manually, I can select all(crtl+a) and copy(ctrl+c), so that part is taken care off. Is there some sort of online tutorial or help guide? I saw the one on the main site, but it's VERY basic and doesn't even mention 98% of the functionality of the program. Back to the macro part. I see it, but don't understand it completely.

// Parse the variable
Variable Set Integer %N1% from Position of Text in Variable %T1%
Variable Set Integer %N2% from Position of Text in Variable %T1%
Variable Modify String: Copy Part of %T1% to %T2%

I got the Variable Set Integer part. %N1% and %T1% I assume you're taking a temporary "thing" into a variable that's concrete? What do those stand for? I also assume the %N1% and%N2% are the begining and end of the clipboard(%t1%)? And then the last line I'm confused at. :)

 

Sorry for the complete newb questions. I've spent endless hours between this and Visual Basic. Found a great book on VB, but nothing but my own guesses on the scripting of this one. :)

 

Thanks!

Link to comment
Share on other sites

F3 does nothing for me, not sure why.

What do you expect F3 to do? Are you thinking of F1 to bring up the help in Macro Express? Another way to bring up the help is to click Help, Macro Express help.

 

You can also view the help online using the 'Help on the Web' link from the Support page. There are also some video tutorials accessible there.

 

// Parse the variable
Variable Set Integer %N1% from Position of Text in Variable %T1%  // Get the position of the beginning text
Variable Set Integer %N2% from Position of Text in Variable %T1%  // Get the position of the ending text
Variable Modify String: Copy Part of %T1% to %T2%

// Copy from T1 beginning at the beginning text and to the ending text and place result in T2

Perhaps the additional comments I added to the example will help. I forgot to add in the step, mentioned in the text, to add a number to N1 big enough to skip over the beginning text. If you do not understand a particular command just highlight it and press F1. The help topic for that command will be displayed.

 

The help available online and within the program explains a lot. In addition the book Macro Express Explained contains more detailed information about the macro commands including the ones you are using. Macro Express Explained is available in PDF format from our website and in book form from major booksellers such as Amazon, Barnes and Noble, and Borders.

Link to comment
Share on other sites

Also, the F3 was for Outlook for the find window. :)

My bad. Sorry. It is F4.

 

The online help that I've looked at and appears to be the same that you point out, are extremely basic and have very simple macros. Am I missing something?

Yes, the help on the web is the same as the help within the program. It describes every macro command and feature. It is not a 'learn how to program' guide, however. As indicated on the support page you can view the sample macros on our Shared Macros web page to get ideas about how to write macros.

Link to comment
Share on other sites

  • 4 months later...

Believe it or not, still working on this one. The problem I'm running in to is that things are random. There isn't a set number of charactors and the numbers are not the same every time. Here's an example of what I'm talking about.

 

<random type>###-#######-#######<random type>

 

The ONLY that is the same every time is that there are '3numbers'-'7numbers'-'7 numbers'.

 

I get saving the clipboard as a variable and then getting rid of the first part and the last part and then saving that to the clipboard, but when you search for something, I need to search for more than '-'. Does any of this make sense?

 

Thanks

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...