Sending Blocks of Text

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
bossydog9
Junior Coder
Posts: 29
Joined: Wed Jan 08, 2020 12:46 pm

Sending Blocks of Text

Post by bossydog9 » Wed Jan 08, 2020 1:16 pm

Hi,

In the Automating Windows for Beginners video, it demonstrates sending text to Notepad using a Send> & Press Enter pair for each line. Is there a way of sending a block of text (and building a string variable) all at once using something like the heredoc method of delimiting multi-line strings in PHP?:

$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;

Regards,

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Sending Blocks of Text

Post by Dorian (MJT support) » Wed Jan 08, 2020 1:42 pm

I'm not a php programmer so am unfamiliar with that. Others here may be able to comment specifically. ReadFile will read an entire text file as one variable, which can then be parsed afterwards.

But you can build strings in a number of ways. For example :

Code: Select all

Let>var1=cat
Let>var2=dog
Let>var3=fish

Let>combinedvars=%var1% %var2% %var3%
messagemodal>combinedvars
Of course your vars could have been taken from a variety of sources - reading Excel, reading a text file, scraping, user entry etc etc.

Now let's say we want to enter a block of text but we don't want to use Send to send the characters one at a time. Sometimes this is actually necessary, as occasionally websites or applications won't like having a lot of text send to them that way.

Here's the way I do that : put the created string into Windows clipboard, then paste it.

Code: Select all

//Your block of text
Let>var1=In the Automating Windows for Beginners video, it demonstrates sending text to Notepad using a Send> & Press Enter pair for each line. Is there a way of sending a block of text (and building a string variable) all at once using something like the heredoc method of delimiting multi-line strings in PHP?:

//Put it in the clipboard
put>%var1%

//Le Notepad so we have somewhere to paste the block
Run>Notepad
WaitWindowOpen>Untitled*
SetFocus>Untitled*
WaitWindowFocused>Untitled*

//Paste it as one block (once you've set focus and have the cursor where you want it
Press Ctrl
Send>v
Release Ctrl
If you have a sample string we'd be happy to give more specific advice.
Yes, we have a Custom Scripting Service. Message me or go here

bossydog9
Junior Coder
Posts: 29
Joined: Wed Jan 08, 2020 12:46 pm

Re: Sending Blocks of Text

Post by bossydog9 » Thu Jan 09, 2020 12:05 am

Thanks for the quick reply, Dorian.

Inserting the system variable %CRLF% in the var1 text achieved what I wanted, perfectly. Many thanks.

Code: Select all

Let>var1=In the Automating Windows for Beginners video, it demonstrates sending text to Notepad using a Send> & Press Enter pair for each line.%CRLF%%CRLF%Is there a way of sending a block of text (and building a string variable) all at once using something like the heredoc method of delimiting multi-line strings in PHP?:%CRLF%%CRLF%In the Automating Windows for Beginners video, it demonstrates sending text to Notepad using a Send> & Press Enter pair for each line.%CRLF%%CRLF%Is there a way of sending a block of text (and building a string variable) all at once using something like the heredoc method of delimiting multi-line strings in PHP?:%CRLF%%CRLF%In the Automating Windows for Beginners video, it demonstrates sending text to Notepad using a Send> & Press Enter pair for each line.%CRLF%%CRLF%Is there a way of sending a block of text (and building a string variable) all at once using something like the heredoc method of delimiting multi-line strings in PHP?:%CRLF%%CRLF%In the Automating Windows for Beginners video, it demonstrates sending text to Notepad using a Send> & Press Enter pair for each line.%CRLF%%CRLF%Is there a way of sending a block of text (and building a string variable) all at once using something like the heredoc method of delimiting multi-line strings in PHP?:%CRLF%%CRLF%
By the way, do string variables have a maximum length and can/do you specify a numeric variable type as an integer, double, long, etc?

Regards,

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Sending Blocks of Text

Post by Dorian (MJT support) » Thu Jan 09, 2020 11:04 am

There's no variable length limit in Macro Scheduler, but there may be one in Windows, or we may run out of system resources. Curiosity got the better of me so I wrote this script which simply builds a very long string.

Letting it loop 25 times pops the message "var1 is 167772160 chars long". Looping it 26 times gave me an out of memory error. So it seems for my system at least, my strings can only be a mere 167.7 million characters.

Code: Select all

let>k=0
let>var1=hello
repeat>k
  let>k=k+1
  let>var1=%var1%%var1%
Until>k,25

len>var1,lenvar1
mdl>var1 is %lenvar1% chars long
The help article on type should answer your other question.
Yes, we have a Custom Scripting Service. Message me or go here

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