0

我想要一些东西,我想知道它是否可能。

我想要的是访问多个 URL 并自动保存屏幕截图。如果可能,屏幕截图的保存名称应与其 URL 相同。

例如,是否可以使用Excelor来执行此操作EmEditor?也许用宏?

是否有可能做到这一点?如果可能的话,我该怎么做?

例子:

网址:3 件(或更多)

  1. https://stackoverflow.com/questions/one
  2. https://stackoverflow.com/questions/two
  3. https://stackoverflow.com/questions/three

自动访问这些链接并保存截图如下。

截图:

  1. stackoverflow.com-questions-one.jpg
  2. stackoverflow.com-questions-two.jpg
  3. stackoverflow.com-questions-three.jpg

注意:该HTTPS://部分可能不在注册名称中,因为注册期间不接受:和标志。//符号也已替换为-符号。

截图 2:

  1. 问题-one.jpg
  2. 问题二.jpg
  3. 问题-三.jpg

注意 2:即使整个 URL 不是文件名。就像上面一样。

我访问了一个类似的问题。但是,提供的信息并没有完全符合我的要求。我尝试了提供的示例代码。例如这段代码

我打开了一个 excel 文件并用 VBA 创建了一个宏并运行它。当宏运行Internet Explorer打开并变成Full Screen. 打开的页面是www.google.com。然后自动截取屏幕截图并保存在WORD文档中。

这不是我想要的。还; 问题中的其他代码根本不起作用。如果上面的例子不能准确地解释我想要什么,请看下面的步骤。

  1. 多个网址会自动一一打开。

(It could be Internet Explorer & Chrome or Edge or anyone.)

  1. 屏幕将被放大并切换到全屏模式。 注意:我这里所说的是使用F11键执行的操作。
  2. 等待“Press key to exit full screen”7 seconds文字在屏幕上消失。F11
  3. 将截取屏幕截图并粘贴到Microsoft Paint.
  4. 屏幕截图将与 URL 名称一起保存。示例:屏幕截图应与当前 URL 后的部分一起保存.com。创建文件名时,链接中的/符号会导致问题。因此,保存屏幕截图时,需要自动将 替换/-符号并保存。

重要的

我不期望您提供任何服务;我只是没有足够的编码知识来做这些。坦率地说,我没有任何名为Code Information. 我非常尊重你们每个人的知识,我想让你们知道我对此是真诚的。我只是一个寻找方法来做我想做的事的人。

我不期望从头开始。如果他们对此问题有任何解决方案,我只是在等待在同一问题上需要帮助的人分享。

4

1 回答 1

1

适用于 Windows 7、8.1、10 的第一种方法

  1. 首先关闭所有窗口。

  2. 打开您的默认 Web 浏览器并最大化浏览器窗口,然后关闭浏览器窗口。

  3. Win+ R,然后键入SnippingTool.exe以运行截图工具。单击Mode按钮(或按Alt+ M)并选择Full Screen。按Ctrl+S显示Save As对话框。我建议创建一个新文件夹(例如Scrn),并将屏幕截图保存在新创建的文件夹中,例如Scrn\screenshot.png. 这只是一个虚拟屏幕截图,您可以稍后将其删除。这样做可以将以下屏幕截图保存到这个新的同一文件夹中。关闭截图工具。

  4. 使用 EmEditor 打开带有 URL 列表的文本文件。请不要最大化 EmEditor 窗口。我建议先用几个 URL 进行测试。文本文件应如下所示:

https://www.emeditor.com/
https://stackoverflow.com/
https://www.google.com/
  1. Finished saving screenshots运行下面的宏(Screenshot1.jsee),在出现对话框之前请不要触摸键盘或鼠标。

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" );

要运行它,请将此代码另存为,例如,Screenshots.jsee然后从菜单中的选择...中选择此文件。最后,在Macros菜单中选择Run Screenshots.jsee 。

注意:如果目标文件夹中存在相同的文件名,则在片段工具提示覆盖时宏将停止。请确保目标文件夹为空或目标文件夹中不存在相同的文件名。

如果出现问题,您可以在 EmEditor 获得键盘焦点时按Ctrl+ Break(或连续两次)取消宏。ESC

Windows 10 的第二种方法

这种方法应该比第一种方法更健壮和更快。

  1. 首先,按Win+PrintScrn并确保屏幕截图保存在您的个人Pictures/Screenshots文件夹中。删除此文件,并确保文件夹为空。

  2. 关闭所有窗户。

  3. 打开您的默认 Web 浏览器并最大化浏览器窗口,然后关闭浏览器窗口。

  4. 使用 EmEditor 打开带有 URL 列表的文本文件。运行下面的宏。

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" );
  1. 您将看到保存在您的个人Pictures/Screenshots文件夹中的屏幕截图。请注意此文件夹路径和第一个文件名(和索引号)。例如,如果文件名是Screenshot (13).png,则索引号是13

  2. 将下面的宏复制到Screenshot3.jsee,并更正文件夹名称 ( sFolder) 和索引号 ( nIndex)。如果您使用的是非英语 Windows 并且文件名不是Screenshot (...).png,您可能还需要更正文件名 ( sFile1)。打开带有 URL 的相同文本文件,然后运行此宏。

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" );
于 2021-09-28T21:35:16.387 回答