Multi Paste Clipboard Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Caporeira
Posts: 14
Joined: 23 Mar 2021, 08:05

Multi Paste Clipboard

14 Dec 2021, 07:24

I want to create something like multi items clipboard.

I have a txt file where i wrote some content, for example:
*EMail Priv.1
1@gmail.com

*EMail Priv.2
2@gmail.com

*Company info1
Company name
Company adres
Some additional date

*Company info2
Company name
Company adres
Some additional date
I want to AHK will read this file and parse it by "*"
On second step i will paste and have possibility to chose, with on this 4 information i want paste it.

How to do this, what ist the easily way ?
Last edited by gregster on 14 Dec 2021, 07:30, edited 1 time in total.
Reason: Topic moved from 'Scripts and Functions'.
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Multi Paste Clipboard

14 Dec 2021, 09:23

Code: Select all

str =
(
*EMail Priv.1
1@gmail.com

*EMail Priv.2
2@gmail.com

*Company info1
Company name
Company adres
Some additional date

*Company info2
Company name
Company adres
Some additional date
)
For each, item in clip := StrSplit(Trim(str, "*"), "*")
 Menu, clips, Add, % SubStr(item, 1, 40), Paste
Gosub, F3

F3::Menu, clips, Show

Paste:
SendInput % "{Text}" clip[A_ThisMenuItemPos]
Return
Caporeira
Posts: 14
Joined: 23 Mar 2021, 08:05

Re: Multi Paste Clipboard

15 Dec 2021, 03:43

mikeyww wrote:
14 Dec 2021, 09:23
Wow !! It's amazing :) Works very well. I'm very grateful.

But how to change two things:

1. Sometimes two last lines are pasted together with by one line (first pasting works good, but second one as above).
2. First line with "*" i need in Menu but not on pasted string.

Please try on my example:

Code: Select all

*Example1
Company name o.o.
Adres. Street 8
50-500 City
Number: 1122334455

*Exampe2
Company: 	Company name o.o.
Adres:	 	Adres. Street 8
			50-500 City
St.-Nr.:	US1122334455

*Example3
Company name o.o.
Adres. Street 8
50-500 City
Number: 1122334455

*Example4
Company: 	Company name o.o.
Adres:	 	Adres. Street 8
			50-500 City
St.-Nr.:	US1122334455

*EMail_1
1@gmail.com

*EMail_2
2@gmail.com
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Multi Paste Clipboard

15 Dec 2021, 05:45

I'm not sure what you mean by #1. Below is a way to remove the first line.

Code: Select all

For each, item in clip := StrSplit(Trim(str, "*"), "*")
 Menu, clips, Add, % SubStr(StrReplace(item, "`n", " "), 1, 40), Paste
Gosub, F3

F3::Menu, clips, Show

Paste:
SendInput % "{Text}" RegExReplace(clip[A_ThisMenuItemPos], ".+?\v",,, 1)
Return
Caporeira
Posts: 14
Joined: 23 Mar 2021, 08:05

Re: Multi Paste Clipboard

15 Dec 2021, 07:04

mikeyww wrote:
15 Dec 2021, 05:45
https://www.dropbox.com/s/n7qhalz74nve857/AHK_paste.png?dl=0
Ok, maybe this example will be more clearly.

My first time pasting are OK - green mark
Every next pasting are wrong - red mark - this should be on new line
Blue mark - it's possible to remove this text ? Not important.
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Multi Paste Clipboard  Topic is solved

15 Dec 2021, 07:12

I ran the following script, testing in Notepad. I did not experience any difficulties. You could run this exact script and also test it in Notepad.

Code: Select all

str =
(
*Example1
Company name o.o.
Adres. Street 8
50-500 City
Number: 1122334455

*Exampe2
Company: 	Company name o.o.
Adres:	 	Adres. Street 8
			50-500 City
St.-Nr.:	US1122334455

*Example3
Company name o.o.
Adres. Street 8
50-500 City
Number: 1122334455

*Example4
Company: 	Company name o.o.
Adres:	 	Adres. Street 8
			50-500 City
St.-Nr.:	US1122334455

*EMail_1
1@gmail.com

*EMail_2
2@gmail.com
)
For each, item in clip := StrSplit(Trim(str, "*"), "*")
 Menu, clips, Add, % SubStr(StrReplace(item, "`n", " "), 1, 40), Paste
Gosub, F3

F3::Menu, clips, Show

Paste:
SendInput % "{Text}" RegExReplace(clip[A_ThisMenuItemPos], ".+?\v",,, 1)
Return
Caporeira
Posts: 14
Joined: 23 Mar 2021, 08:05

Re: Multi Paste Clipboard

15 Dec 2021, 11:34

mikeyww wrote:
15 Dec 2021, 07:12
I ran the following script, testing in Notepad. I did not experience any difficulties. You could run this exact script and also test it in Notepad.
It works ! :)

But for reason on Example2 and Example4, the last line is moved by 3 tabs:

Code: Select all


Company: 	Company name o.o.
Adres:	 	Adres. Street 8
			50-500 City
            St.-Nr.:	US1122334455
Should looks like this:

Code: Select all

Company: 	Company name o.o.
Adres:	 	Adres. Street 8
			50-500 City
St.-Nr.:	US1122334455
PS. I have change this line of code:

Code: Select all

 Menu, clips, Add, % RegExReplace(item, "`n.*", " "), Paste
 ;Menu, clips, Add, % SubStr(item, 1, 40), Paste
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Multi Paste Clipboard

15 Dec 2021, 12:37

You are using Notepad, the Windows program?

My output from my script is below.

Company name o.o.
Adres. Street 8
50-500 City
Number: 1122334455

Company: Company name o.o.
Adres: Adres. Street 8
50-500 City
St.-Nr.: US1122334455

Some text editors provide their own approaches to tabulation and white space. This has nothing to do with the script.
Caporeira
Posts: 14
Joined: 23 Mar 2021, 08:05

Re: Multi Paste Clipboard

31 May 2022, 05:38

And how to avoid run script every start my windows system ?
After start my computer, popup menu from script is displayed.

I want to display this menu from script only after print key F3
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Multi Paste Clipboard

31 May 2022, 05:45

And how to avoid run script every start my windows system ?
You can place a shortcut to your script within Windows' StartUp-folder.
It's path has to be set accordingly :arrow: https://www.autohotkey.com/docs/Scripts.htm#cmd
After start my computer, popup menu from script is displayed.
#SingleInstance, Force :think:
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Multi Paste Clipboard

31 May 2022, 12:35

Gosub, F3 in the auto-exec section shows the menu when the script runs. You can delete that line.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Mateusz53, MrHue, mstrauss2021, Rohwedder and 324 guests