How to keep adding to clipboard memory content Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

How to keep adding to clipboard memory content

Post by M4verick » 16 Jan 2022, 22:31

First, here is my script:

Code: Select all

;  Run Youtube-dl program
NumpadSub::
clipboard := ""
Click Right ; invokes the right click context menu
Sleep, 500
Send, {l} ; this copies the hyperlink under the mouse cursor
ClipWait, 1
clipboard := "youtube-dl.exe " clipboard
WinActivate, AHK_class ConsoleWindowClass
Sleep, 500
Send, %clipboard%{Enter}
Return
There is nothing with this script. However, there are times when I want to grab multiple links as I scroll down a particular webpage. So what I would like to change in the script is every time I press the hotkey NumpadSub, copy whatever link is under the mouse cursor, and then every time I press the same hotkey, add the 2nd hyperlink and 3rd hyperlink (and so & so forth) WITHOUT deleting the 1st hyperlink and add a space in between each link. I will manually move the mouse cursor to the appropriate spot on the webpage. I just need the hotkey to continually add the hyperlink to clipboard memory content.

For example: youtube-dl.exe https:\\www.abc.com https:\\www.def.com https:\\www.ghi.com https:\\www.jkl.com

And finally when I press the combo hotkey Shift + NumpadSub - paste the clipboard contents into the command console window.

Is this possible?

User avatar
boiler
Posts: 16772
Joined: 21 Dec 2014, 02:44

Re: How to keep adding to clipboard memory content

Post by boiler » 16 Jan 2022, 22:48

Yes. Store the contents of the clipboard in a variable before you clear it and copy in the contents to be added. Then assign the old contents and the the newly copied stuff to the clipboard.

Code: Select all

;  Run Youtube-dl program
NumpadSub::
OrigClip := clipboard
clipboard := ""
Click Right ; invokes the right click context menu
Sleep, 500
Send, {l} ; this copies the hyperlink under the mouse cursor
ClipWait, 1
clipboard := OrigClip . A_Space . clipboard
Return

+NumpadSub::
WinActivate, AHK_class ConsoleWindowClass
Sleep, 500
Send, %clipboard%{Enter}
Return

You don’t even need to be using the clipboard to store the cumulated links. You could be storing them in another variable like the this:

Code: Select all

;  Run Youtube-dl program
NumpadSub::
clipboard := ""
Click Right ; invokes the right click context menu
Sleep, 500
Send, {l} ; this copies the hyperlink under the mouse cursor
ClipWait, 1
Links .= clipboard . A_Space ; the ".=" adds it onto the end of Link's current contents
Return

+NumpadSub::
WinActivate, AHK_class ConsoleWindowClass
Sleep, 500
SendInput, % RTrim(Links) . "{Enter}" ; RTrim removes the trailing space
Return

+NumpadAdd::Links := "" ; press Shift+NumpadAdd to clear the variable

M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: How to keep adding to clipboard memory content

Post by M4verick » 16 Jan 2022, 23:36

Boiler, thanks for the response. I'm having trouble making your code work.

I need "youtube-dl.exe " added to the very beginning like so:

youtube-dl.exe https:\\www.abc.com https:\\www.def.com https:\\www.ghi.com https:\\www.jkl.com

User avatar
boiler
Posts: 16772
Joined: 21 Dec 2014, 02:44

Re: How to keep adding to clipboard memory content  Topic is solved

Post by boiler » 17 Jan 2022, 00:17

OK. Then do it like this:

Code: Select all

;  Run Youtube-dl program
NumpadSub::
clipboard := ""
Click Right ; invokes the right click context menu
Sleep, 500
Send, {l} ; this copies the hyperlink under the mouse cursor
ClipWait, 1
Links .= A_Space . clipboard ; the ".=" adds it onto the end of Link's current contents
Return

+NumpadSub::
WinActivate, AHK_class ConsoleWindowClass
Sleep, 500
SendInput, % "youtube-dl.exe" . Links . "{Enter}"
Return

+NumpadAdd::Links := "" ; press Shift+NumpadAdd to clear the variable

M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: How to keep adding to clipboard memory content

Post by M4verick » 17 Jan 2022, 00:26

Excellent. Thank you very much Boiler!

Post Reply

Return to “Ask for Help (v1)”