Pasting from Clipboard Line by Line  SOLVED

User-to-User discussion about the PhraseExpress macro programming.
Post Reply
SandBird
Posts: 2
Joined: 11 May 19, 22:07

Pasting from Clipboard Line by Line

Post by SandBird » 11 May 19, 22:17

Hello,
I have searched the forms briefly but with no luck.

What I am trying to do is to paste line at a time from clipboard.
Scenario steps:
1. Copy a multi line text (a list) to the clipboard.
2. Use a hotkey to paste the first line.
3. Using the same hotkey again, will paste the 2nd line from that same clipboard and so on.

Is it possible?

Any help would greatly appreciated.

Thanks in advance!

Using PhraseExpress Free 14.0.139f for Windows

Peter Stotz
PhraseExpress Expert
Posts: 823
Joined: 27 Feb 08, 15:07

Post by Peter Stotz » 13 May 19, 06:24

My suggestion:

Code: Select all

(* 20190513 • Outputs the currently first line of the clipboard content
   Delete empty lines from the clipboard (RegEx)
*){#setclipboard {#trim {#regexrep -text {#insertclipboard} -expr ^\h*\R -repexpr }}{#asc 13}}(* 
  Output line 1 of the current clipboard content
*)»{#trim {#substr {#insertclipboard} -from 1 -count {#calc {#pos {#insertclipboard} -substr {#asc 13}}-1 -round 0}}}«(* 
  Remove line 1 from clipboard content
*){#setclipboard {#substr {#insertclipboard} -from {#calc {#pos {#insertclipboard} -substr {#asc 13}}+1 -round 0} -count }}
The best way to use the macro program is to assign a hotkey to it.
Peter
Windows 10 - PhraseExpress v14.0.143

SandBird
Posts: 2
Joined: 11 May 19, 22:07

Post by SandBird » 13 May 19, 06:34

Hello Peter,

Thank you so much, simply amazing - this works!

mh348
Posts: 8
Joined: 29 Aug 18, 10:30

Post by mh348 » 16 Feb 20, 11:09

Hi Peter, is there any way to adapt this to paste the 3rd paragraph only from the clipboard?

Also if possible for the code to work on PE Android & Windows..

I'm basically copying a tweet which has mentions to other twitter users (all start with a @ sign) and a url, so Alternatively if not all macro functions are supported on Android (to copy exact paragraph), then if the code can just strip out all mentions (all words starting with @) and all urls.

Example text/tweet I copy:

ExampleA

Code: Select all

#UPDATE 1

Date: 16 February 2020

Today's update is as follows, hello sample text
@Peter @mh348
@John @ JaneDoe https://www.phraseexpress.com/docsa2/09/manual.htm
ExampleB

Code: Select all

#UPDATE 2
Date: 16 February 2020

For today the following occurred

@Peter @mh348 @John @ JaneDoe https://www.phraseexpress.com/docsa2/09/manual.htm
I only need the text
ExampleA "Today's update is as follows, hello sample text."
ExampleB "For today the following occurred"

Each days wording is different

Peter Stotz
PhraseExpress Expert
Posts: 823
Joined: 27 Feb 08, 15:07

Post by Peter Stotz » 16 Feb 20, 19:19

@mh348
This code for Windows extracts the 3rd paragraph from the clipboard:

Code: Select all

(* 20200216 • Select the 3rd paragraph from the clipboard content
  1. Delete empty lines from the clipboard (RegEx)
*){#setclipboard {#trim {#regexrep -text {#insertclipboard} -expr ^\h*\R -repexpr }}{#asc 13}}(*
  2. Remove the 1st and 2nd paragraph from the clipboard content
*){#loop {#setclipboard {#substr {#insertclipboard} -from {#calc {#pos {#insertclipboard} -substr {#asc 13}}+1 -round 0} -count }} -count 2}(*
  3. Select the 3rd paragraph for output
*){#trim {#substr {#insertclipboard} -from 1 -count {#calc {#pos {#insertclipboard} -substr {#asc 13}}-1 -round 0}}}
Peter
Windows 10 - PhraseExpress v14.0.177

Post Reply