Extract certain data from clipboard

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Leevan
Newbie
Posts: 9
Joined: Sun Jan 27, 2013 4:09 pm

Extract certain data from clipboard

Post by Leevan » Sun Jan 27, 2013 4:22 pm

I am just starting using Macro Schedule.
I copied some data into clipboard like:
user name "Johe Doe" DBO "10/10/185" ID "12345678" Location "LA"

GetClipBoard>mydata
MessageModal>mydata

I can see all the data in clipboard, I need extract "John Doe" and "12345678" put them into an excel file.
Can someone give me sample code?

Thanks,

Leevan

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Mon Jan 28, 2013 2:24 pm

This is how I would do it.. if I know that the clipboard will always look the same that is!

Code: Select all

//Make a "nice" message box...
Let>MSG_STAYONTOP=1
Let>MSG_HEIGHT=300
Let>MSG_WIDTH=500

//Add clipboard for example
PutClipBoard>user name "Johe Doe" DBO "10/10/185" ID "12345678" Location "LA"
GetClipBoard>mydata

//Putting info in the text variable
Let>TEXT_TO_DISPLAY=CLIPBOARD: %mydata%
Message>TEXT_TO_DISPLAY

//Add a replacable variable for entire script... this make it simple to change in the future
Let>SUBSTRING_TO_LOOK_FOR="

//Find the first " sign for the user name...
Position>%SUBSTRING_TO_LOOK_FOR%,mydata,0,Pos1_UserName,FALSE
//Because we start on "0" and look for the substring " we need to add 1 for the 0 and 1 for the next digit after "
Let>Pos1_UserName=%Pos1_UserName%+2
Let>NEXT_TEXT_TO_DISPLAY=FIRST POSITION: %Pos1_UserName%
Let>TEXT_TO_DISPLAY=%TEXT_TO_DISPLAY%%CRLF%%NEXT_TEXT_TO_DISPLAY%
Wait>1
Message>TEXT_TO_DISPLAY

//Find the second "
Position>%SUBSTRING_TO_LOOK_FOR%,mydata,%Pos1_UserName%,Pos2_UserName,FALSE
Let>NEXT_TEXT_TO_DISPLAY=SECOND POSITION: %Pos2_UserName%
Let>TEXT_TO_DISPLAY=%TEXT_TO_DISPLAY%%CRLF%%NEXT_TEXT_TO_DISPLAY%
Wait>1
Message>TEXT_TO_DISPLAY

//Get length of user name and get the user nam...
Let>Length_UserName=%Pos2_UserName%-%Pos1_UserName%
MidStr>mydata,%Pos1_UserName%,%Length_UserName%,UserName
Let>NEXT_TEXT_TO_DISPLAY=BETWEEN %Pos1_UserName% AND %Pos2_UserName% WE HAVE: %UserName%
Let>TEXT_TO_DISPLAY=%TEXT_TO_DISPLAY%%CRLF%%NEXT_TEXT_TO_DISPLAY%
Wait>1
Message>TEXT_TO_DISPLAY

//Continue with the ID the same way but start by finding the fifth " 
The Wait>1 command is only to slow the script down...
Let>ME=%Script%

Running: 15.0.27
version history

Leevan
Newbie
Posts: 9
Joined: Sun Jan 27, 2013 4:09 pm

Post by Leevan » Tue Jan 29, 2013 12:41 am

Grovkillen,
Thank you very much.
It is what I am looking for.

Leevan

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts