Copy some data and store it to an Array without leaving current page

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
rjw524
Pro Scripter
Posts: 104
Joined: Wed May 09, 2012 9:45 pm
Location: Michigan

Copy some data and store it to an Array without leaving current page

Post by rjw524 » Sun Jun 04, 2023 7:40 pm

Hello,

So I know this is probably SIMPLE but I'm stuck...

So let's say I'm on a site like EBay or Amazon and I'm looking through pages of items I want to store in an array to look at later. I may view something close to 500 pages and want to store 200 of them for instance.

For my purposes, I want to copy and send the URLs of the pages I like to an array that I will export to Excel when I'm finished.

I'm trying to avoid the process of copying in one program and pasting to another. I'd like to hit a hotkey to store the URL to the Array and keep moving until finished.

NOTES:

1) I'm using a work computer and I CANNOT use EdgeBrowser or ChromeBrowser commands on my computer. Each time I do this the computer opens a new session and requests that I log in to the session.

2) I want the URLs. I do not want to use a screenshot based workaround.

This is a script I wrote based on a post I found in the forums here that looked close to what I'm trying to do, but I don't believe I tailored it correctly and it's not returning anything in the array.

Code: Select all

Let>LastValue=

Press ALT
wait 0.01
Send d
wait 0.01
Release ALT
wait 0.01
Press CTRL
wait 0.01
Send c
wait 0.01
Release CTRL
Wait 0.01
Press Esc

Label>UpdateLastValue
Let>LastValue=%LastValue%;%NewValue%

wait 0.1

MDL>%LastValue%
Any help would be appreciated!

hagchr
Automation Wizard
Posts: 331
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Copy some data and store it to an Array without leaving current page

Post by hagchr » Mon Jun 05, 2023 6:01 am

Hi, you need to use the clipboard value, eg

Code: Select all

GetClipBoard>NewValue

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Copy some data and store it to an Array without leaving current page

Post by Dorian (MJT support) » Mon Jun 05, 2023 8:52 am

The other issue is that each time you hit your hotkey the script will just remember the last URL.

I'd be inclined to write it to a text file.

Code: Select all

//Omit line break characters from the end of the line
Let>WLN_NOCRLF=1

Let>LastValue=
Press ALT
wait 0.01
Send d
wait 0.01
Release ALT
wait 0.01
Press CTRL
wait 0.01
Send c
wait 0.01
Release CTRL
Wait 0.01
Press Esc

GetClipBoard>NewValue
writeln>d:\URLS.txt,,%NewValue%;

Then just read it back. You could even do something like this at the beginning of your script, append your new value to AllValues, then write it back, if you wish (but i may be over-complicating things).

Code: Select all

readln>d:\URLS.txt,1,AllValues
mdl>AllValues
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Copy some data and store it to an Array without leaving current page

Post by JRL » Mon Jun 05, 2023 3:21 pm

I agree with Dorian. Save to a file.
I don't know who came up with the Alt + D. I prefer Ctrl + L. Its supposed to work in all web browsers and also works in Windows File Explorer.

You could also add a dialog or message at the end that displays for a second to let you know the hotkey worked.

Code: Select all

Wait>0.2
Press Ctrl
Send>l
Release Ctrl
Press Ctrl
Send>c
Release Ctrl
Wait>0.3
GetClipBoard>URL
WriteLn>%temp_Dir%URL_List.txt,wres,URL
Press Esc

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Copy some data and store it to an Array without leaving current page

Post by Dorian (MJT support) » Mon Jun 05, 2023 3:40 pm

Ooh, I wasn't aware of CTRL + L.

Thank you for that. I think I discovered Alt-D from a list of Chrome keyboard shortcuts years ago and tested it successfully in IE and Edge (but not in any other browsers).

I much prefer CTRL over ALT, so will use that instead in future.
Yes, we have a Custom Scripting Service. Message me or go here

rjw524
Pro Scripter
Posts: 104
Joined: Wed May 09, 2012 9:45 pm
Location: Michigan

Re: Copy some data and store it to an Array without leaving current page

Post by rjw524 » Mon Jun 05, 2023 7:00 pm

JRL wrote:
Mon Jun 05, 2023 3:21 pm
I agree with Dorian. Save to a file.
I don't know who came up with the Alt + D. I prefer Ctrl + L. Its supposed to work in all web browsers and also works in Windows File Explorer.

You could also add a dialog or message at the end that displays for a second to let you know the hotkey worked.

Code: Select all

Wait>0.2
Press Ctrl
Send>l
Release Ctrl
Press Ctrl
Send>c
Release Ctrl
Wait>0.3
GetClipBoard>URL
WriteLn>%temp_Dir%URL_List.txt,wres,URL
Press Esc
Thanks so much to all of you guys on this! I'm going to try this out! I think writing to a file makes perfect sense. That does exactly what I need it to do!

rjw524
Pro Scripter
Posts: 104
Joined: Wed May 09, 2012 9:45 pm
Location: Michigan

Re: Copy some data and store it to an Array without leaving current page

Post by rjw524 » Mon Jun 05, 2023 7:49 pm

Hi all,

Ok so this is the code I used:

Code: Select all

Wait>0.2
Press Ctrl
Send>l
Release Ctrl
Press Ctrl
Send>c
Release Ctrl
Wait>0.3
GetClipBoard>URL
WriteLn>C:\Users\userID\OneDrive - MyCompany\Documents\URL_List.txt,wres,%URL%
Press Esc
So when I tried the code I changed the %temp_Dir% path to the actual path I wanted to save the file to and got the following results:

Code: Select all

GetClipBoard>URL
WriteLn>C:\Users\userID\OneDrive - MyCompany\Documents\URL_List.txt,wres,URL
Press Esc

GetClipBoard>URL
WriteLn>C:\Users\userID\OneDrive - MyCompany\Documents\URL_List.txt,wres,URL
Press Esc

GetClipBoard>URL
WriteLn>C:\Users\userID\OneDrive - MyCompany\Documents\URL_List.txt,wres,URL
Press Esc
So, then I changed URL to the GetClipboard variable %URL% and I got the following every time I ran the macro:

Code: Select all

%URL%
%URL%
%URL%
Any ideas on what I'm doing wrong?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Copy some data and store it to an Array without leaving current page

Post by Dorian (MJT support) » Mon Jun 05, 2023 10:23 pm

rjw524 wrote:
Mon Jun 05, 2023 7:49 pm

Code: Select all

GetClipBoard>URL
WriteLn>C:\Users\userID\OneDrive - MyCompany\Documents\URL_List.txt,wres,URL
Press Esc

GetClipBoard>URL
WriteLn>C:\Users\userID\OneDrive - MyCompany\Documents\URL_List.txt,wres,URL
Press Esc

GetClipBoard>URL
WriteLn>C:\Users\userID\OneDrive - MyCompany\Documents\URL_List.txt,wres,URL
Press Esc
If this is what was in your txt file, my guess is that's what was in the clipboard if you were copying and pasting within the script editor. So maybe your script is not actually copying the URL. My hunch is that it's possibly running a little too fast and needs some very small waits inbetween keystrokes. Feel free to edit them to reach the sweet spot.

Code: Select all

Wait>0.2
Press Ctrl
Wait>0.1
Send>l
Wait>0.1
Release Ctrl
Wait>0.1
Press Ctrl
Wait>0.1
Send>c
Wait>0.1
Release Ctrl
Wait>0.3
GetClipBoard>URL
WriteLn>C:\Users\userID\OneDrive - MyCompany\Documents\URL_List.txt,wres,%URL%
Press Esc
Yes, we have a Custom Scripting Service. Message me or go here

rjw524
Pro Scripter
Posts: 104
Joined: Wed May 09, 2012 9:45 pm
Location: Michigan

Re: Copy some data and store it to an Array without leaving current page

Post by rjw524 » Tue Jun 06, 2023 10:18 pm


If this is what was in your txt file, my guess is that's what was in the clipboard if you were copying and pasting within the script editor. So maybe your script is not actually copying the URL. My hunch is that it's possibly running a little too fast and needs some very small waits inbetween keystrokes. Feel free to edit them to reach the sweet spot.

Code: Select all

Wait>0.2
Press Ctrl
Wait>0.1
Send>l
Wait>0.1
Release Ctrl
Wait>0.1
Press Ctrl
Wait>0.1
Send>c
Wait>0.1
Release Ctrl
Wait>0.3
GetClipBoard>URL
WriteLn>C:\Users\userID\OneDrive - MyCompany\Documents\URL_List.txt,wres,%URL%
Press Esc
You were right Dorian, it just needed a little more time to do it's thing! Thanks!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts