There is something I want and I want to know if it is possible.
What I want is to visit multiple URLs and automatically save screenshots. And if possible, the save name of the screenshot should be the same as its URL.
For example, would it be possible to do this with Excel
or EmEditor
?
Maybe with macro?
Is it possible to do this? And if possible how can I do it?
EXAMPLE:
URLS: 3 Pieces (Or More)
Visiting these links automatically and saving screenshots as below.
Screenshots:
- stackoverflow.com-questions-one.jpg
- stackoverflow.com-questions-two.jpg
- stackoverflow.com-questions-three.jpg
Note: The HTTPS://
part may not be in the registration name, as :
and /
signs will not be accepted during registration.
Also the /
symbol has been replaced with a -
sign.
Screenshots 2:
- questions-one.jpg
- questions-two.jpg
- questions-three.jpg
Note 2: Even if the entire URL is not the filename. Just like above.
I visited a similar question. However, the information presented did not do exactly what I wanted. I tried the sample codes provided. For example this code.
I opened an excel file and created a macro with VBA and ran it.
When the macro ran Internet Explorer
opened and became Full Screen
.
The page that opened was www.google.com
.
Then the screenshot was automatically taken and saved in the WORD
document.
This is not what I want. Also; The other code in the question didn't work at all. If the above example doesn't explain exactly what I want, please see the steps below.
- Multiple URLs will be opened one by one automatically.
(It could be Internet Explorer & Chrome or Edge or anyone.)
- The screen will be enlarged and switched to full screen mode. Note: What I'm talking about at this point is the action performed with the F11 key.
- Wait
7 seconds
for the text "Press the F11 key to exit full screen" disappears on the screen.- A screenshot will be taken and pasted into
Microsoft Paint
.- The screenshot will be saved with the URL name. Sample: Screenshots should be saved with the part of the current URL after
.com
. The/
sign in the links will cause problems when creating the filename. Therefore, when saving the screenshot, it will be necessary to automatically replace the/
with a-
sign and save it as such.
IMPORTANT
I do not expect any service from you; I just don't have enough coding knowledge to do them.
To be frank, I do not have any information under the name of Code Information
.
I respect the knowledge of each of you very much and I want you to know that I am sincere about it.
I'm just someone looking for a way to do what I want.
I don't expect anything from scratch on this; I'm just waiting for someone who needs help on the same issue before to share if they have any solution on this issue.
CodePudding user response:
First Method for Windows 7, 8.1, 10
Close all windows first.
Open your default web browser and maximize the browser window, and close the browser window.
Press Win R, and type
SnippingTool.exe
to run the Snipping Tool. clickMode
button (or press Alt M) and selectFull Screen
. Press Ctrl S to show theSave As
dialog box. I recommend creating a new folder (for example,Scrn
), and save a screenshot in the new created folder, such asScrn\screenshot.png
. This is just a dummy screenshot, and you can delete it later. Doing this allows the following screenshots saved into this new same folder. Close the Snipping Tool.Open the text file with a list of URLs with EmEditor. Please don't maximize the EmEditor window. I would recommend testing with a few URLs first. The text file should look like this:
https://www.emeditor.com/
https://stackoverflow.com/
https://www.google.com/
- Run the macro (Screenshot1.jsee) below, and please don't touch keyboard or mouse until you see
Finished saving screenshots
in a dialog box.
Screenshot1.jsee
document.selection.StartOfDocument();
nLines = document.GetLines();
for( y = 1; y <= nLines; y ) {
str = document.GetLine( y ); // retrieve an URL at a line
if( str.length != 0 ) {
str = str.replace("http://", ""); // remove "http://" and "https://"
str = str.replace("https://", "");
if( str.charAt( str.length - 1 ) == '/' ) { // remove the last slash character
str = str.substr( 0, str.length - 1 );
}
str = str.replace("/", "-"); // replace invalid characters with "-"
str = str.replace("~", "-");
str = ".png"; // append ".png"
document.selection.OpenLink();
document.selection.LineDown(false,1);
Sleep( 5000 ); // wait for the browser to become active and show the webpage completely
WshShell = new ActiveXObject( "WScript.Shell" );
WshShell.Run( "SnippingTool.exe" );
Sleep( 2000 ); // wait for the Snipping Tools appears
shell.SendKeys( "%M" ); // Press Alt M
Sleep( 100 );
shell.SendKeys( "s" ); // Press s
Sleep( 100 );
shell.SendKeys( "%n" ); // Press Alt N
Sleep( 1000 );
shell.SendKeys( "~" ); // Press Enter
Sleep( 100 );
shell.SendKeys( "~" ); // Press Enter
Sleep( 1000 );
shell.SendKeys( "%{F4}" ); // Press Alt F4 to close Snipping Tools
Sleep( 1000 );
shell.SendKeys( "y" ); // select YES
Sleep( 1000 );
shell.SendKeys( str "~" ); // enter file name
Sleep( 1000 );
shell.SendKeys( "%{F4}" ); // Press Alt F4 to close web browser
Sleep( 1000 );
}
}
alert( "Finished saving screenshots" );
To run this, save this code as, for instance, Screenshots.jsee
, and then select this file from Select... in the Macros menu. Finally, select Run Screenshots.jsee in the Macros menu.
Notes: If the same file names exist in the destination folder, the macro will stop when the Snippets Tools prompts for overwrite. Please make sure the destination folder is empty or that same file names don't exist in the destination folder.
If something went wrong, you can cancel the macro by pressing Ctrl Break (or ESC twice consecutively) while EmEditor has the keyboard focus.
Second Method for Windows 10
This method should be more robust and faster than the first method.
First, press Win PrintScrn and make sure a screenshot is saved in your personal
Pictures/Screenshots
folder. Delete this file, and ensure the folder is empty.Close all windows.
Open your default web browser and maximize the browser window, and close the browser window.
Open the text file with a list of URLs with EmEditor. Run the macro below.
Screenshot2.jsee
document.selection.StartOfDocument();
nLines = document.GetLines();
for( y = 1; y <= nLines; y ) {
str = document.GetLine( y ); // retrieve an URL at a line
if( str.length != 0 ) {
document.selection.OpenLink();
Sleep( 5000 ); // wait for the browser to become active and show the webpage completely
shell.SendKeys( "{LWIN DOWN}{PRTSC}{LWIN UP}" );
Sleep( 500 );
shell.SendKeys( "%{F4}" ); // Press Alt F4 to close web browser
Sleep( 500 );
}
document.selection.LineDown(false,1);
}
alert( "Finished saving screenshots" );
You will see screenshots saved in your personal
Pictures/Screenshots
folder. Note this folder path, and the first file name (and the index number). For example, if the file name isScreenshot (13).png
, the index number is13
.Copy the macro below to
Screenshot3.jsee
, and correct the folder name (sFolder
) and index number (nIndex
). If you are using non-English Windows and the file name is notScreenshot (...).png
, you might also need to correct the file name (sFile1
). Open the same text file with URLs, and then run this macro.
Screenshot3.jsee
sFolder = "C:\\Users\\...\\Pictures\\Screenshots\\"; // Screenshots folder where files are saved on [Win] [PrintScrn]. Use double-backslashes "\\".
sFile1 = "Screenshot ("; // screenshot file name before index number
nIndex = 13; // index number of first screenshot, for example, 13 for Screenshot (13).png
sFile2 = ").png"; // screenshot file name after index number
fso = new ActiveXObject( "Scripting.FileSystemObject" );
document.selection.StartOfDocument();
nLines = document.GetLines();
for( y = 1; y <= nLines; y ) {
str = document.GetLine( y ); // retrieve an URL at a line
if( str.length != 0 ) {
str = str.replace("http://", ""); // remove "http://" and "https://"
str = str.replace("https://", "");
if( str.charAt( str.length - 1 ) == '/' ) { // remove the last slash character
str = str.substr( 0, str.length - 1 );
}
str = str.replace(/[/<>:\\|?*\"]/g, "-"); // replace invalid characters with "-"
str = ".png"; // append ".png"
sSrc = sFolder sFile1 nIndex sFile2;
sDest = sFolder str;
fso.MoveFile( sSrc, sDest );
}
document.selection.LineDown(false,1);
nIndex;
}
alert( "Finished renaming screenshots" );