Paste multiple lines of a clipboard item separately Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Elermino
Posts: 114
Joined: 29 Nov 2021, 17:43

Paste multiple lines of a clipboard item separately

Post by Elermino » 16 Dec 2023, 19:11

Hello everyone
In this script I tried to do the following:
*I copy several lines. Ex:
(
line1
line2
line3
)

These lines look like 1 single element on the clipboard, so if I do Ctrl+V, all the text is pasted.
What I would like to achieve is to detect line breaks and paste the lines one by one and press enter to paste the next one. Ex:
(
line1 → *sticks* → {enter}
line2 → *sticks* → {enter}
line3 → *sticks*
)

Thank you in advance, this forum is very useful ;)

Script:

Code: Select all

!a::
Loop, Read, clipboard
{
send %A_LoopReadLine%
sleep 200
}
return

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Paste multiple lines of a clipboard item separately

Post by mikeyww » 16 Dec 2023, 19:34

Code: Select all

#Requires AutoHotkey v1.1.33

A_Clipboard := "
(
line1
line2
line3
)"

!a::
line := StrSplit(A_Clipboard, "`n", "`r")
SoundBeep 1500
#If line.Length()
Enter::SendInput % "{Text}" line.RemoveAt(1)
#If

User avatar
Elermino
Posts: 114
Joined: 29 Nov 2021, 17:43

Re: Paste multiple lines of a clipboard item separately

Post by Elermino » 16 Dec 2023, 19:44

Thanks for your answer. I would like the last item copied from the clipboard to be handled, line1, line2, line3 was an example. Maybe autohotkey v1 code?
Regards :thumbup:

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Paste multiple lines of a clipboard item separately

Post by mikeyww » 16 Dec 2023, 19:47

What this AutoHotkey v1 script does:
What I would like to achieve is to detect line breaks and paste the lines one by one and press enter to paste the next one
You are welcome to test the script to see if it works.

User avatar
Elermino
Posts: 114
Joined: 29 Nov 2021, 17:43

Re: Paste multiple lines of a clipboard item separately

Post by Elermino » 16 Dec 2023, 19:53

Sorry, maybe I didn't make myself understood. I would like everything to happen automatically.
(
line1
line2
line3
)
It is done as if it were a macro
(
line1 {enter}
line2 {enter}
line3
)

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Paste multiple lines of a clipboard item separately

Post by mikeyww » 16 Dec 2023, 20:11

If you mean something other than what you wrote, then I recommend a detailed explanation of how pasting the clipboard contents-- or whatever you wish to achieve-- will differ from pressing Ctrl+V.

User avatar
Elermino
Posts: 114
Joined: 29 Nov 2021, 17:43

Re: Paste multiple lines of a clipboard item separately

Post by Elermino » 16 Dec 2023, 20:26

I explain my case to you. I want to insert a list of tags in Facebook Marketplace, and if you copy a list and paste it directly, it is inserted as a single tag (instead of detecting the line breaks and placing them individually), which is why I want to make a script since It makes it repetitive to copy and paste the tags of a list for the products one by one.

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Paste multiple lines of a clipboard item separately  Topic is solved

Post by mikeyww » 16 Dec 2023, 20:29

Code: Select all

#Requires AutoHotkey v1.1.33

A_Clipboard := " ; Demonstration
(
line1
line2
line3
)"

!a::
SetKeyDelay 35, 25
SendEvent % "{Text}" A_Clipboard
Return

User avatar
Elermino
Posts: 114
Joined: 29 Nov 2021, 17:43

Re: Paste multiple lines of a clipboard item separately

Post by Elermino » 16 Dec 2023, 20:49

Working at 100, many thanks :wave:

Post Reply

Return to “Ask for Help (v1)”