NeVeR Posted July 14, 2010 Report Share Posted July 14, 2010 As the title says i'm trying a new macro where I high light a block of text, the macro removes what i dont need and then copies what's left and let me paste it where i need. I know some of you might say why am i copying it to begin with,, but i dont have a choice. I''m copying this info from a website. All I need are the numbers from the 1st column, But there are 5 colume's most have a single digit in them, Some have 2 digits. Also the word "status" comes up in front of the numbers i need. I need the macro to copy all of it.. remove that i dont need and leave me with what i need. Does anyone know what i can do ?. Quote Link to comment Share on other sites More sharing options...
rberq Posted July 14, 2010 Report Share Posted July 14, 2010 See if you can (manually) copy the screen contents by clicking on the screen, highlighting all with Ctrl-a, then copying to the clipboard. Paste the result into Notepad, then post an example of the Notepad text here on the forum, pointing out what fields you need to capture. Once we can see the text data, we can advise you how to parse it and remove what is unwanted. Quote Link to comment Share on other sites More sharing options...
acantor Posted July 14, 2010 Report Share Posted July 14, 2010 What you are trying to do can probably be done. I think you might have an easier time if you use Macro Express Pro, because it supports user-supplied variable names: Instead of using built-in variables %T1% and %N1%, you can give variables names like %CopiedText% and %Column1%. My guess is that you will be manipulating a lot of variables to get the results you want. Yes, please send a sample of the kind of text you want to manipulate. Quote Link to comment Share on other sites More sharing options...
rberq Posted July 14, 2010 Report Share Posted July 14, 2010 I will respectfully disagree about ME Pro. I have found it all-around clumsier and less user-friendly than ME3. Quote Link to comment Share on other sites More sharing options...
acantor Posted July 17, 2010 Report Share Posted July 17, 2010 I will respectfully disagree about ME Pro. I have found it all-around clumsier and less user-friendly than ME3. I agree, but it is possible to make ME Pro less clumsy. I use a program called "Macro Express Pro" for this purpose. I have almost 40 program and window specific scripts to streamline Macro Express. I prefer ME Pro when scripts use a lot of variables. One macro I rely on needed 14 variables. It was a lot easier to debug, and is easier to maintain, with variables names like %PixelColour% and %MousePositionX% instead of %N1% and %N99%. Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 18, 2010 Author Report Share Posted July 18, 2010 Sorry for the delay in getting back to you. I've attached an image of what i would be copying. Here is a copy and paste of the info. Accounts Devices In Common Other Devices Associated Accounts Device Exceptions status 14770512 7 0 5 1 status 14807254 2 3 5 0 status 14828829 2 2 5 0 status 9262022 1 2 1 0 status 11934759 1 0 3 0 status 14947735 1 5 3 0 Please look at both so you can see the word "Status" is not in the screen shot , The green circle is in it's place. I didnt remove anything this is how it copies. The info i need to extract from this is the 7 or 8 digit code after the word status. Also in the above sample there is 6 lines this could be any amount, The goal at the end is to have those 7/8 digit numbers saves into a CRTL+(anything) key so i can paste them into another program. Thanks for the help. Quote Link to comment Share on other sites More sharing options...
PotterHarry Posted July 18, 2010 Report Share Posted July 18, 2010 I have achieved this by using: Mouse Move Screen Mouse Left Button Down Mouse Move Position (Relative to the last position) Mouse Left Button UP Clipboard copy. Then assign contents of the clipboard to another variable. This would work if your rows of numbers appear in a fixed place on the screen. In your exmple there is a row of numbers with a stray '1' That would mess things up somewhat. Amazingly I was looking on the forum for a solution to a problem I have, and your question, top of the list, was on the same topic! I have obtained a clipboard variable using the method I described, and I want to remove the alpha characters nd, rd, th from 3rd 4th 5th etc. Will be very interested in your answers! Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 18, 2010 Author Report Share Posted July 18, 2010 Highlighting the text is not a problem. It's the actions after it I need help with. Quote Link to comment Share on other sites More sharing options...
rberq Posted July 20, 2010 Report Share Posted July 20, 2010 Once the data is in the clipboard, put it a variable like T1. Then: Variable Set String T2 = "" (empty) Repeat Start Variable Set Integer N1 to position of "status" in T1 If N1 = 0 Repeat Exit End If Variable Modify String Delete N1 characters from the beginning of T1 Variable Modify String Delete 7 more characters from the beginning of T1 (to get rid of "status ") Variable Set Integer N2 to position of first blank space in T1 Variable Modify String append N2 characters from the beginning of T1 to the end of T2 Repeat End When this repeat loop finishes, the numeric strings will be stacked in T2 with one blank space between each string (and after the final string). Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 21, 2010 Author Report Share Posted July 21, 2010 Once the data is in the clipboard, put it a variable like T1. Then: Variable Set String T2 = "" (empty) Repeat Start Variable Set Integer N1 to position of "status" in T1 If N1 = 0 Repeat Exit End If Variable Modify String Delete N1 characters from the beginning of T1 Variable Modify String Delete 7 more characters from the beginning of T1 (to get rid of "status ") Variable Set Integer N2 to position of first blank space in T1 Variable Modify String append N2 characters from the beginning of T1 to the end of T2 Repeat End When this repeat loop finishes, the numeric strings will be stacked in T2 with one blank space between each string (and after the final string). I'm at this point below and I cant figure out where to find this. I was in "Variable Modify String" and selected D2Delete Part of Text" but i cant sent anything to T1 Variable Modify String Delete N1 characters from the beginning of T1 Same with this.. No idea where i enter 7. Variable Modify String Delete 7 more characters from the beginning of T1 (to get rid of "status ") Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 21, 2010 Author Report Share Posted July 21, 2010 here's a screen shot of what I have so far.. Nearly sure it's wrong tho. Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 21, 2010 Author Report Share Posted July 21, 2010 Oh i moved the "Repeat End" to the bottom and added a "repeat exit". Just so you know Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 21, 2010 Author Report Share Posted July 21, 2010 Would you be able to post screen shots of each stage. I know it's alot to ask but it's wrecking my head. Quote Link to comment Share on other sites More sharing options...
rberq Posted July 21, 2010 Report Share Posted July 21, 2010 Some of the script editor commands, especially for setting and modifying variables, have a lot of options. And you have to click the right radio button before you see some of the sub-options. Sorry, I can't post images, but keep looking within the basic commands and you will find where to enter what you need. Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 22, 2010 Author Report Share Posted July 22, 2010 @ rberq: are you sure what you said will work ?.. I dont mind trying it but if i'm not going to get anywhere there's no point.. But i will try. Thanks Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 22, 2010 Author Report Share Posted July 22, 2010 How does the macro know not to delete the info i need?... anything i try just leave me with nothing (blank) Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 22, 2010 Author Report Share Posted July 22, 2010 If anyone else can help me on this please do. I've messed with it for 2 days and i'm getting no where. Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 22, 2010 Author Report Share Posted July 22, 2010 can you review the screen shots i've added. Once the data is in the clipboard, put it a variable like T1. Then: See Image 1 below. Is this right ? Variable Set String T2 = "" (empty) See Image 2 below. Is this right ? Repeat Start Variable Set Integer N1 to position of "status" in T1 See Image 3 below. Is this right ? If N1 = 0 Repeat Exit End If Variable Modify String Delete N1 characters from the beginning of T1 See Image 4 below. Is this right ? Variable Modify String Delete 7 more characters from the beginning of T1 (to get rid of "status ") See Image 5 below. Is this right ? Variable Set Integer N2 to position of first blank space in T1 See Image 6 below. Is this right ? Variable Modify String append N2 characters from the beginning of T1 to the end of T2 See Image 7 below. Is this right ? Repeat End Thanks. Quote Link to comment Share on other sites More sharing options...
kevin Posted July 22, 2010 Report Share Posted July 22, 2010 To see what your macro is doing, use the built-in debugger. Click Debug, Debug Windows, Variable Values to bring up the Variables window. Then press the F8 key to step through your macro one command at a time. The Variables window will show you what is contained in each of the variables as a result of that step. For more information read the help topic Editor Menu - Debug. As has been mentioned earlier, Macro Express contains a number of commands that allow you to manipulate the contents of variables. There are very few things that cannot be done using the Variable Set and Variable Modify commands. (With the possible exception of processing large arrays, and that is handled by Macro Express Pro.) The help describes each of the options in these commands. Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 22, 2010 Author Report Share Posted July 22, 2010 Ill check it out Kevin thanks. didnt know about the debugger. Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 22, 2010 Author Report Share Posted July 22, 2010 Ok i got it to remove the word status and it displays it like this 14770512 7 0 9 1 4807254 2 3 5 0 4828829 2 3 6 0 262022 1 2 1 0 1934759 1 0 3 0 4947735 1 5 7 0 5780319 1 0 5 0 5780389 1 0 5 0 5785904 1 0 5 0 5786067 1 0 5 0 Which is great Now i've to try remove the other digits. What does the "Append" string do for my macro ? Quote Link to comment Share on other sites More sharing options...
rberq Posted July 22, 2010 Report Share Posted July 22, 2010 You're doing pretty well. But: Image 4 -- starting position should be Value 1, rather than N1. Image 5 -- starting position should be Value 1. Image 6 -- Looks good. Since you are searching for a single blank, you have to actually type a single blank into the Search Text -- since it is blank, I can't tell from the image whether it is there or not. Image 7 -- This is a tricky one, and I led you astray a little bit. You will need two instructions -- Variable Modify String copy part of T1 to T5, then Variable Modify String append T5 to the end of T2. Be careful not to get the "to" and the "from" backwards when you append. Quote Link to comment Share on other sites More sharing options...
NeVeR Posted July 23, 2010 Author Report Share Posted July 23, 2010 would it be easier to copy the digits i needs instead of deleting the numbers at the end ? I can remove the status word.. then copy the 1st 8 digits ? Quote Link to comment Share on other sites More sharing options...
rberq Posted July 23, 2010 Report Share Posted July 23, 2010 Yes, that would be easier if it is always 8 digits, but some of your examples were not 8. Here's something you could try: Once your number is at the beginning of the text string, try Variable Modify String Convert to Integer. It's really sloppy programming, but as I recall Macro Express will take the string of characters, until it finds a non-numeric, and convert it. Then Variable Modify Integer Convert to Text String to get it back to text. Quote Link to comment Share on other sites More sharing options...
lemming Posted July 26, 2010 Report Share Posted July 26, 2010 If you're not averse to using an external program, you can use Sed to extract the digits with just two Sed commands: /status/!d s/status \([0-9]\{7,8\}\) .*$/\1/ The first line removes any lines that do not contain the work "status". The second line extracts any 7 or 8 digits after the word "status". Sed is part of GNU utilities for Win32 (unxutils.sourceforge.net), which includes other classic Unix utilities like Grep and Awk. These 3 support regular expressions, and I got them to work with Macro Express Pro. QUICK START 1. Download Sed numbers.mxe and Sed numbers.zip from here 2. Unzip Sed numbers.zip and put the 3 files (sed.exe, Sed_Script.txt, NeVeR.txt) into a folder which MEP can read. Take note of the folder path. Also note that Windows 7/Vista may block access to certain folders. 3. Import Sed numbers.mex into Macro Express Pro 4. Change the WorkingFolder variable in the script to the full path of the folder which contains the 3 files from Step #2 5. Run the script, and it will process NeVeR.txt and report the results The Sed_Script.txt file has comments which explain the Sed commands. I also learned a lot from this site: Famous Sed One-Liners Explained Sed numbers.mxe Sed numbers.zip Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.