Pasting Clipboard loop

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AutoHelpKey
Posts: 7
Joined: 28 Sep 2022, 08:50

Pasting Clipboard loop

Post by AutoHelpKey » 28 Sep 2022, 09:00

I have been trying different methods for a while to solve an issue (see below code)
I have a task that I need to select an email, pasted it into a box, press enter and then repeat.

Unfortunately I can't type all the required emails into the submit box at once, and autohotkey seems to be typing too quickly for some methods to work.
If required, I can put the emails into an array for a method to work, but obviously I want to streamline the task as much as possible.

I want to basically select all emails, copy to clipboard, click on the box I need to paste to, then press function button, pastes first email then pause for a few seconds for the program to update before moving into the next email in the clipboard.

As an example:
So I would copy the following to clipboard (ctrl C)
testing1@hotmail.com
testing2@gmail.com
testing3@outlook.com
testing4@whatsever.com
testing5@autohot.com

then function button (windows b for example)
paste testing1@hotmail.com
press enter
pause for loading

paste testing2@gmail.com
paste press enter
pause for loading

paste testing3@outlook.com
press enter
pause for loading

paste testing4@whatsever.com
press enter
pause for loading

paste testing5@autohot.com
press enter
pause for loading

Please let me know of any ideas you may have. I've been playing around with this for a while.


/*

Code: Select all

#b::
Loop, parse, clipboard 
 { 
    send %A_LoopField%
			if (A_LoopField == ".com") ;will add other domains once working
				Send {Enter}
		sleep, 30          ;delay in ms 

  } 
Return

Code: Select all

#b::
cellArray := ["testing1@hotmail.com",
"testing2@gmail.com",
"testing3@outlook.com",
"testing4@whatsever.com",
"testing5@autohot.com",]

for i, element in cellArray ; Read all elements of cellArray
{
  MsgBox, Yes, the element belongs to the array. %i%, %element% ; Message + Number and element as info
  cell := cellArray[i+1] ; Pick next element
  MsgBox, %cell% ; Show next element in a message box
}
return
*/

/*

Code: Select all

#b::
myCopiedClipboard := Trim(clipboard)
Sleep, 100
linesInArraySeperatedbyNewLine := []

Loop, Parse, myCopiedClipboard, `n, `r
	if Trim(A_LoopField)
		linesInArraySeperatedbyNewLine.Push(A_LoopField)

MsgBox, % linesInArraySeperatedbyNewLine.MaxIndex()
; Just testing to see how many lines I read in

Loop, 1
	{
	Send, %myCopiedClipboard% 
	Sleep, 1000
	Send, {ENTER 2} ; separator
	}

Return
*/

Rohwedder
Posts: 7717
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Pasting Clipboard loop

Post by Rohwedder » 28 Sep 2022, 09:47

Hallo,
try:

Code: Select all

ClipBoard =
(
testing1@hotmail.com
testing2@gmail.com
testing3@outlook.com
testing4@whatsever.com
testing5@autohot.com
)
#b::
SetKeyDelay, 100, 100
Loop, parse, clipboard, `n, `r
{
	SendEvent,% A_LoopField
	SendEvent, {Enter}
	Sleep, 1000
}

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Pasting Clipboard loop

Post by Lepes » 28 Sep 2022, 10:04

There is not a fixed way to do any programming task. Each people thinks in a different way so there are too many solutions. I like the first one, there was only missing the last parameter that makes cut the string when if find a `ror may be `n

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


/*
text to be present on clipboard before exectuing:
testing1@hotmail.com
testing2@gmail.com
testing3@outlook.com
testing4@whatsever.com
testing5@autohot.com


*/


;#b::
Loop, parse, clipboard , "`n"
 { 
    MsgBox, % A_LoopField
    ;send %A_LoopField%
			if (A_LoopField == ".com") ;will add other domains once working
				Send {Enter}
		sleep, 30          ;delay in ms 

  } 
Return

AutoHelpKey
Posts: 7
Joined: 28 Sep 2022, 08:50

Re: Pasting Clipboard loop

Post by AutoHelpKey » 29 Sep 2022, 03:08

Hi guys,
Thank you for your help
The following (with the advice of Lepes) seems to work.

Code: Select all

;#b::
Loop, parse, clipboard , "`n"
 { 
    ;MsgBox, % A_LoopField
    send %A_LoopField%
			if (A_LoopField == ".com") ;will add other domains once working
				Send {Enter}
		sleep, 1000          ;delay in ms 

  } 
Return
What is confusing though is why. I'd like to understand rather than just hope it doesn't go wrong.
The loop still works and copies and enters all clipboard contents, even if it does not end with a .com

If somebody wants to test:
testing1@hotmail.com
testing2@gmail.test
testing3@outlook.ahk
testing4@whatsever.co
testing5@autohot.eu

AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Pasting Clipboard loop

Post by AHKStudent » 29 Sep 2022, 03:31

AutoHelpKey wrote:
29 Sep 2022, 03:08
Hi guys,
Thank you for your help
The following (with the advice of Lepes) seems to work.

Code: Select all

;#b::
Loop, parse, clipboard , "`n"
 { 
    ;MsgBox, % A_LoopField
    send %A_LoopField%
			if (A_LoopField == ".com") ;will add other domains once working
				Send {Enter}
		sleep, 1000          ;delay in ms 

  } 
Return
What is confusing though is why. I'd like to understand rather than just hope it doesn't go wrong.
The loop still works and copies and enters all clipboard contents, even if it does not end with a .com

If somebody wants to test:
testing1@hotmail.com
testing2@gmail.test
testing3@outlook.ahk
testing4@whatsever.co
testing5@autohot.eu
because you have this

Code: Select all

send %A_LoopField%

Post Reply

Return to “Ask for Help (v1)”