Wednesday, September 30, 2020

#1 2020-08-11 03:38:58 am

epaminos
Member
Registered: 2019-10-18
Posts: 68

Linebreaks

Hello guys,

I want to paste a specific text to an internal email app.

The script is:

Applescript:



set AppleScript's text item delimiters to {return & linefeed, return, linefeed, character id 8233, character id 8232}
set mytext to "Order number: " & ordernumber & "\nDate: " & ddate & "\nDelivery number: " & delnumber & "\n\nHello " & name & ","



set the clipboard to mytext
tell application "System Events" to keystroke "v" using command down

However the text is pasted without line breaks when the script is executed.

The interesting thing is that elsewhere (Notes, Word, etc) it works as expected, only in the specific internal mail app I see it a single line. Is there any other workaround?

Last edited by epaminos (2020-08-11 03:42:25 am)

Offline

 

#2 2020-08-11 12:01:06 pm

kerflooey
Member
Registered: 2011-07-07
Posts: 189

Re: Linebreaks

Hi, have you tried using a CR, like:

     ordernumber & (return) & "Date: "

Offline

 

#3 2020-08-11 05:34:40 pm

epaminos
Member
Registered: 2019-10-18
Posts: 68

Re: Linebreaks

Hi,

Thanks for your reply. Yes, I had tried with the return keys but no luck.

Then hopefully I thought of splitting the text to lines and deployed the following solution, which is not optimal but at least it works:

Applescript:

set the clipboard to myline1
               delay 0.4
               tell application "System Events" to keystroke "v" using command down
               tell application "System Events" to key code 36
               set the clipboard to myline2
               delay 0.2
               tell application "System Events" to keystroke "v" using command down
               tell application "System Events" to key code 36
               set the clipboard to myline3
               delay 0.2
               tell application "System Events" to keystroke "v" using command down
               tell application "System Events" to key code 36
               tell application "System Events" to key code 36
               set the clipboard to myline4

Last edited by epaminos (2020-08-11 05:36:48 pm)

Offline

 

#4 2020-08-11 10:37:19 pm

TMA
Member
Registered: 2005-11-24
Posts: 70

Re: Linebreaks

You can also use:

ASCII character 10 --LF LineFeed
or
ASCII character 13 --CR CarriageReturn

Offline

 

#5 2020-08-11 10:50:19 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1311

Re: Linebreaks

Try to replace the first code line of your original script with this:

Applescript:

set AppleScript's text item delimiters to ""


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#6 2020-08-13 03:10:18 pm

epaminos
Member
Registered: 2019-10-18
Posts: 68

Re: Linebreaks

I tried them both but unfortunately no luck.... sad

Offline

 

#7 2020-08-13 04:16:00 pm

robertfern
Member
Registered: 2011-11-29
Posts: 68

Re: Linebreaks

I don't know why you are talking about "Text Item Delimiters".
No where in the code are you converting text to a list or vice-versa.
So it is completely irrelevant.

Or am I missing something?

Did you try:

Applescript:

set mytext to "Order number: " & ordernumber & return & "Date: " & ddate & return & "Delivery number: " & delnumber & return & return & "Hello " & name & ","

set the clipboard to mytext
tell application "System Events" to keystroke "v" using command down

Last edited by robertfern (2020-08-13 04:18:27 pm)

Online

 

#8 2020-08-13 05:39:39 pm

epaminos
Member
Registered: 2019-10-18
Posts: 68

Re: Linebreaks

Thanks for the reply.

Yes, I had tried that as well. Both the (return) and the "\n" without luck.

But as I mentioned above, I splitted the text to lines and so the new script (third post) pastes them one by one as I wanted.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)