Passing clipboard data into VBScript for processing?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
NexxTech
Newbie
Posts: 5
Joined: Tue Nov 11, 2008 11:40 pm

Passing clipboard data into VBScript for processing?

Post by NexxTech » Tue Nov 11, 2008 11:49 pm

Hi All,

This is my first day using Macro Scheduler, read the tutorials and have been using it for a few hours.

I want to write a macro to copy some text from the screen, manipulate it in some way (like uppercasing some words, formating others) and then replacing the selected text with the new formatted text. I have all the keystrokes in place I am just not able to pass in the clipboard data into a VBScript function. I have created a very simple macro, maybe someone can tell me why it does not work?

Code: Select all

VBSTART

Function MyLower(var)
  MyLower = LCase(var)
End Function

VBEND

PutClipBoard>Hello World
WAIT 1
GetClipBoard>text

VBEval>MyLower(text),text1
MessageModal>text1
The message dialog is blank - any idea why "Hello World" is not displayed in upper case in the dialog box? :?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Nov 12, 2008 1:07 am

I'm not your best source for VBscript but in this case I think I know the answer. Your VBEval line should read:

VBEval>MyLower("%text%"),text1

Vbscript wants quotes around text and Macro Scheduler wants percents around the variable for proper evaluation.

I would also like to point out that MAcro Scheduler can do this particular task without VBScript by using "complex expression". (see help)

Code: Select all


PutClipBoard>Hello World
WAIT 1
GetClipBoard>text

Let>text1={lower(%text%)}
MessageModal>text1

NexxTech
Newbie
Posts: 5
Joined: Tue Nov 11, 2008 11:40 pm

Post by NexxTech » Wed Nov 12, 2008 10:11 am

JRL wrote:I'm not your best source for VBscript but in this case I think I know the answer. Your VBEval line should read:

VBEval>MyLower("%text%"),text1

Vbscript wants quotes around text and Macro Scheduler wants percents around the variable for proper evaluation.

I would also like to point out that MAcro Scheduler can do this particular task without VBScript by using "complex expression". (see help)

Code: Select all


PutClipBoard>Hello World
WAIT 1
GetClipBoard>text

Let>text1={lower(%text%)}
MessageModal>text1
That did it! :) Thanks.

The reason why I want to VBScript is because I would like to do quite a bit of manipulation of the text.

My idea is to select addresses from a webpage, and paste them, nicely formatted into a address label application for printing. So this parsing would for example, trimming, removing multiple spaces in between words, uppercase the first letter of each word, look for zip codes or postcodes and uppercase them completely (so through the use of regular expressions) hence VBscript.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Nov 12, 2008 10:38 am

Don't forget to double quote existing quotes and remove line breaks before passing strings to VBScript. See:
http://www.mjtnet.com/blog/2008/07/24/quoting-quotes/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

NexxTech
Newbie
Posts: 5
Joined: Tue Nov 11, 2008 11:40 pm

Post by NexxTech » Wed Nov 12, 2008 2:04 pm

mtettmar wrote:Don't forget to double quote existing quotes and remove line breaks before passing strings to VBScript. See:
http://www.mjtnet.com/blog/2008/07/24/quoting-quotes/
Ah thanks for the tip - very useful link :)

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