Automatic line breaks after 50 characters?

Discussion, questions and support.
Post Reply
User avatar
BrittMalka
Posts: 9
Joined: Jul 4th, ’17, 18:12

Post by BrittMalka » May 30th, ’21, 10:39

Hi,

When I send out autoresponder emails, I copy the email text to clipboard.

Then I paste it into https://www.formatit.com and click Submit to have hard returns after each 50 characters.

Can FastKeys be set up to do the same?

I would love to be able to:

1. Copy the text to clipboard
2. Format it to 50 characters wide - perhaps by using a FastKeys shortcut.

Can this be done?

And if so, how?

(I have FastKeys v. 5.03 Pro.)

Thanks,
Britt
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » May 31st, ’21, 11:56

Sure. Create a shortcut with the script below (Type: Command). It will copy the selected text to clipboard and replace it with the formatted text.

Code: Select all

send, ^c
sleep 200
text:=""
loop, parse, clipboard
{
	If (Mod(A_Index, 50) = 0)
		text := text A_LoopField "`n"
	Else 
		text := text A_LoopField
}
sendinput % text
return
User avatar
BrittMalka
Posts: 9
Joined: Jul 4th, ’17, 18:12

Post by BrittMalka » May 31st, ’21, 12:51

Thanks.

It didn't work that well for me.

It took this text:

People love to do the work themselves.

Funny, eh?

Instead of you taking care of printing a file, the customer prefers to do it themselves.

Printables, which can be PDF files or images, are in high-demand.

The customer gets it instantly. No waiting time. And they can print it ourselves.

But when you check printables on Etsy and other places, you’ll see that many of them are priced at $2 or $3.

Then why would anyone pay $80?

That’s what Paul Coleman set out to find out.

And he figured it took four things:

Higher perceived value.

Higher prices.

The right audience.

The right categories.

Then he gives examples and tell you how you can get those four things.

It’s not even difficult.

https://clq.cx/hvpp

***

And turned it into this:

People love to do the work themselves.



Funny, e
h?



Instead of you taking care of printing a fil
e, the customer prefers to do it themselves.



Pr
intables, which can be PDF files or images, are intables high-demand.



The customer gets it instantly. N
o waiting time. And they can print it ourselves.




But when you check printables on Etsy and other
places, you’ll see that many of them are priced at
$2 or $3.



Then why would anyone pay $80?



Theat’s what Paul Coleman set out to find out.



And he figured it took four things:



Higher perceiv
ed value.



Higher prices.



The right audience.




The right categories.



Then he gives example
s and tell you how you can get those four things.




It’s not even difficult.



https://clq.cx/hvpp

***

I tried copying with my new short cut both from ProWritingAid and Notepad++

I tried changing the short cut to another one to see if it made a difference, but it didn't.
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » May 31st, ’21, 15:18

Your request was not clear. I corrected the script to only format the lines longer than 50 characters.

Code: Select all

send, ^c
sleep 100
text:=""
loop, parse, clipboard, `n
{
	if (StrLen(A_LoopField>50))
	{
		loop, parse, A_LoopField
		{
			k:=A_LoopField
			If (Mod(A_Index, 50) = 0)
				text := text k "`n"
			Else 
				text := text k
		}
		text := text "`n"
	}
	else
		text := text A_LoopField "`n"
}
clipboard:=text
sleep 100
send ^v
return
User avatar
BrittMalka
Posts: 9
Joined: Jul 4th, ’17, 18:12

Post by BrittMalka » May 31st, ’21, 19:41

Thank you. That one worked much better.

Is there a way to format the lines that are longer than 50 characters to not cut through words but leave the words whole?

In the example, it gave me:

Code: Select all

The customer gets it instantly. No waiting time. A
nd they can print it ourselves.
And

Code: Select all

Then he gives examples and tell you how you can ge
t those four things.
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » Jun 1st, ’21, 18:08

How about this?

Code: Select all

width:=50
send, ^c
sleep 100
text:=""

loop, parse, clipboard, `n, `r
{
	i:=A_Index
	if (StrLen(A_LoopField)>width)
	{
		spos:=1
		loop
		{
			k:=SubStr(A_LoopField, spos, width)
			if (StrLen(k)=0)
				break
			epos:=InStr(k, " ",, 0)
			if (epos=0) or (StrLen(k)<width)
				epos:=50
			k:=SubStr(k, 1, epos)
			spos:=spos+StrLen(k)
			text := text ((i=1 and not text)?"":"`n") k
		}
	}
	else
		text := text ((i=1 and not text)?"":"`n") A_LoopField
}
clipboard:=text
sleep 100
send ^v
return
User avatar
BrittMalka
Posts: 9
Joined: Jul 4th, ’17, 18:12

Post by BrittMalka » Jun 2nd, ’21, 06:22

Yes!

Perfect!

Thank you so much. This is brilliant.

Thank you so so much!
Post Reply