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
Extract certain data from clipboard
Moderators: Dorian (MJT support), JRL
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
This is how I would do it.. if I know that the clipboard will always look the same that is!
The Wait>1 command is only to slow the script down...
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 "