有谁知道可以从 JavaScript 调用来创建和保存桌面屏幕截图的无 GUI 应用程序?

发布于 2024-07-11 05:30:24 字数 700 浏览 5 评论 0原文

虽然这个话题听起来像是我想做一些狡猾的事情,但我不是; 我维护一个由数百个电话运营商使用的内部网站,并希望添加以下功能:

我想在所有网页的标题中添加一个控件,该控件将捕获整个桌面的图像并保存图像作为文件保存到共享网络驱动器,以帮助解决生产问题。 该屏幕捕获应用程序将由 JavaScript 调用。

我已经研究了该网站上与捕获屏幕截图有关的许多线程,并且所有提供的应用程序都无法通过以下两种方式之一满足我的需求:

  1. 屏幕捕获应用程序有一个弹出的 GUI,用户可以调整一些尺寸某种捕获控件或与窗口交互以进行捕获。 用户不太懂计算机,并且不能相信他们能够正确使用“弹出”应用程序,并且不可能强制他们使用通用文件命名约定来保存图像文件。 我希望用户按下网站上的单个 UI 控件,并让 JavaScript 进行调用以获取屏幕截图并保存图像,而无需任何进一步的用户交互。

  2. 一些自动化应用程序通过重新发布到网站来保存 HTML,并将各个 HTML 元素“重新组装”成图像。 这将不起作用,因为操作员输入的输入数据需要在图像中,该站点使用 AJAX,因此网页的视觉“状态”将与从 POST 重新获取的状态不同,并且某些应用程序在尝试与我们的(安全)网站交互时遇到(活动目录)安全问题。

如果没有可以满足此需求的应用程序,我将在 C# 中推出自己的控件。 但我宁愿获得第三方控制。 所以我不必终生支持自己的控制。 :-)

While the subject could sound like I'm looking to do something shifty, I'm not; I maintain an internal web site used by several hundred phone operators, and would like to add the following functionality:

I would like to add a control in the header of all of the web pages that would capture an image of the entire desktop and save the image as a file to a shared network drive to assist in troubleshooting production problems. This screen capture app would be called by JavaScript.

I've researched many threads on this site pertaining to capturing screenshots, and all of the offered applications don't meet my need in one of two ways:

  1. The screen capture application has a GUI that pops up and the user sizes some sort of capture control or interacts with a window to do the capture. The users are not very computer literate, and could not be trusted with using a "pop-up" application correctly-- and it would be impossible to enforce them to save the image file with a common file naming convention. I would like the user to press a single UI control on a web site and have JavaScript make the calls to obtain a screen shot and save the image without any further user interaction.

  2. Some automated applications save the HTML by re-posting to the site and "re-assembles" the individual HTML elements into an image. This will not work as the input data that the operator has typed in needs to be in the image, the site uses AJAX so the visual "state" of the web page will be different from one re-obtained from a POST, and some applications have had (active directory) security issues when trying to interact with our (secured) web sites.

If there isn't an application that will meet this need, I'll just roll my own control in C#. But I'd rather obtain a third-party control. so I don't have to support my own control for life. :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

三生池水覆流年 2024-07-18 05:30:24

由于安全风险,Javascript 不提供对本地系统的访问以实现此功能。

我相信在网页上执行此操作的唯一方法可能是通过 Active X 控件或 Java 小程序(类似于 screencast-o-matic),但即便如此,安全也可能是一个问题。

我还想象,除非您自己的 C# 控件位于 Windows 窗体应用程序中,否则它将无法工作,因为作为网站一部分的 C# 控件将在服务器上运行,而不是在客户端上运行。

希望这个对你有帮助。

Javascript does not provide access to the local system for this functionality due to the security risk.

I believe the only way of doing this on a web page is possibly via an active X control or Java applet (similar to screencast-o-matic) but even then security may be an issue.

I also image unless your own c# control is in a windows forms application it would not work as c# controls that are part of a web site will be run on the server and not the client.

Hope this is of some help.

狼性发作 2024-07-18 05:30:24

要做到这一点,您需要一些与桌面交互的东西,而这不能仅通过 javascript 来完成。

您需要有一个 Active X 对象才能与客户端的计算机进行交互。 一旦你有了它,就可以很容易地让对象拍照并将其保存到目录中。

我相信我有 C# 代码来截屏。 如果你想要我会发布它。

Well to do that you'll need something to interact with the desktop which can't be done by javascript alone.

You'll need to have an Active X Object to be able to interact with the client's machine. Once you have that, it is easy to just have the object take a picture and save it to the directory.

I believe I have the C# code to take a screen shot. If you want I'll post it.

眼藏柔 2024-07-18 05:30:24

ActiveX / Java 的一些替代方案:

  • 您可以创建一个 Flash 程序来执行屏幕捕获。 我没有这样做过,也不知道细节,但我相当确定它可以完成。

  • 您可以为屏幕捕获设置自定义协议(例如screencapture:// ),并在标题中包含

    屏幕截图

关联。 您需要找到一个无 GUI 的屏幕捕获程序来执行实际捕获并将其设置为该自定义协议的处理程序。

Some alternatives to ActiveX / Java:

  • You can create a flash program to do the screen capture. I haven't done this and don't know the details, but I'm fairly sure it can be done.

  • You can setup a custom protocol for screen capture (eg. screencapture:// ), and in your header include a

    <a href="screencapture://this/">Screen Capture</a>

link. You'll need to find a gui-less screen capture program to do the actual capturing and set it up as the handler for that custom protocol.

把梦留给海 2024-07-18 05:30:24

做过一次。 我找不到直接的方法,所以它使用 html2canvas 将 HTML 渲染到画布,然后将画布渲染到图像。 画布到图像是一个更常见的主题,因此您会找到许多相关教程。

HTML 到 Canvas

画布到图像

注意:从 HTML 渲染到画布可能会留下一些元素,例如 SVG。 但总体来说,它的表现符合预期。

Did it once. I couldn't find a direct way so did it rendering HTML to canvas, then canvas to image using html2canvas. Canvas to image is a much more common theme so you'll find many tutorials about.

HTML to Canvas

Canvas to image

NOTE: rendering from HTML to canvas may leave some elements behind, like SVG. But overall it did as much as expected.

桃酥萝莉 2024-07-18 05:30:24

PSR(问题步骤记录器)是用于在客户端计算机上进行调试的出色工具,并且默认情况下在所有 Windows 计算机上都可用。

请尝试下面的内容,看看它是否适合您。

转到“开始”->“运行”并输入 psr.exe(或只是 psr),这将打开记录器。 这相当容易使用,因此即使用户/客户也可以使用它。 如果有效,请尝试以下步骤进行设置。

第1步:注册PSR协议。 这告诉浏览器当页面上的链接引用 PSR 协议(我们将用它来打开此记录器)时该怎么做。
- 创建注册表值如下

HKEY_CLASSES_ROOT/
  PSR/
    (Default)    "URL:PSR Protocol"
    URL Protocol ""
    shell/
      open/
        command/
          (Default) psr.exe

如果您不习惯创建注册表值,请下载并双击 文件。

  • 使用链接了解更多信息。

第 2 步:现在创建一个示例 html 文件来测试启动 PSR。
将以下代码保存到index.html 文件并打开它。

<html>
   <head>
      <head>
   </head>
   <body>
      <a href="psr:start">Start Recording</a>
   </body>
   </head>
</html>

或者下载文件并打开它。

这应该会打开您的 PSR。 它使用方便,可以记录调试所需的所有信息。

PSR (problem step recorder) is a great tool for debugging purposes on client machines and it is available on all windows machines by default.

Try below and see if it works for you.

Go to Start->Run and type psr.exe (or just psr) this should open the recorder. This is fairly easy to use, so even users/clients can use it. If it works then try below steps to setup.

Step 1: Register PSR protocol. This tells the browser what to do when a link on the page is referring to PSR protocol (which we will use to open this recorder).
- Create registry values as below

HKEY_CLASSES_ROOT/
  PSR/
    (Default)    "URL:PSR Protocol"
    URL Protocol ""
    shell/
      open/
        command/
          (Default) psr.exe

If you are not comfortable with creating registry values, download and double click this file.

  • Use this link for more information.

Step 2: Now create an example html file to test launching PSR.
Save the below code to index.html file and open it.

<html>
   <head>
      <head>
   </head>
   <body>
      <a href="psr:start">Start Recording</a>
   </body>
   </head>
</html>

Or download this file and open it.

This should open your PSR. It is easy to use and can record all the information you need for debugging.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文