Adobe AIR 桌面应用程序可以拍摄全屏快照(也称为“打印屏幕”按钮)

发布于 2024-09-04 00:13:30 字数 167 浏览 4 评论 0 原文

我想知道是否可以从空中应用程序获取全屏快照。 我感兴趣的是类似于 Windows 中 PrintScreen 按钮的功能,它可以拍摄所有屏幕的快照,包括第三方应用程序窗口,而不仅仅是运行 Air 应用程序的窗口。 如果它不是特定于air的,并且flash/flex API可以提供这样的功能,那就太好了。 提前非常感谢。

I would like to know if its possible to get full screen snapshots from an air application.
What i am interested in, is functionality similar to PrintScreen button in windows, which takes snapshots of all screens, including third party application windows, not just window in which air app is running.
If its not specific to air, and flash/flex API can provide such functionality, it also would be great.
Thanx a lot in advance.

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

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

发布评论

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

评论(1

挖个坑埋了你 2024-09-11 00:13:30

查看这篇文章解释了如何通过调用本机进程获取屏幕截图:

import flash.filesystem.File;
import flash.events.NativeProcessExitEvent;

var process:NativeProcess;

if(NativeProcess.isSupported) {

    var file:File = File.applicationDirectory;
    var args:Vector.<String> = new Vector.<String>();

    if (Capabilities.os.toLowerCase().indexOf("win") > -1) {
        file = file.resolvePath("PATH/TO/WINDOWS/printscr");
        //use your prefered screenshot tool here (e.g. https://code.google.com/p/screenshot-cmd/
        //also setup the args as needed
    } else if (Capabilities.os.toLowerCase().indexOf("mac") > -1) {
        file = file.resolvePath("/usr/sbin/screencapture");
        args[0] = "-i";
        args[1] = "screencapture.png";
    }




    var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
    nativeProcessStartupInfo.arguments = args;
    nativeProcessStartupInfo.executable = file;
    nativeProcessStartupInfo.workingDirectory = File.desktopDirectory;

    process = new NativeProcess();
    process.start(nativeProcessStartupInfo);
    process.addEventListener(NativeProcessExitEvent.EXIT,done);

}else trace("NativeProcess NOT SUPPORTED!");

function done(e:NativeProcessExitEvent):void{
    trace("screenshot comprete");
}

需要记住的一件重要事情是AIR 设备配置文件
如果您最初在 ADL 中进行测试,请务必使用 extendedDesktop 配置文件,否则 NativeProcess.isSupported 将返回 false

有关更多详细信息,请查看 NativeProcess 文档AIR 开发人员指南中的与本机进程通信

Check out this article as it explains obtaining a screenshot by calling a native process:

import flash.filesystem.File;
import flash.events.NativeProcessExitEvent;

var process:NativeProcess;

if(NativeProcess.isSupported) {

    var file:File = File.applicationDirectory;
    var args:Vector.<String> = new Vector.<String>();

    if (Capabilities.os.toLowerCase().indexOf("win") > -1) {
        file = file.resolvePath("PATH/TO/WINDOWS/printscr");
        //use your prefered screenshot tool here (e.g. https://code.google.com/p/screenshot-cmd/
        //also setup the args as needed
    } else if (Capabilities.os.toLowerCase().indexOf("mac") > -1) {
        file = file.resolvePath("/usr/sbin/screencapture");
        args[0] = "-i";
        args[1] = "screencapture.png";
    }




    var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
    nativeProcessStartupInfo.arguments = args;
    nativeProcessStartupInfo.executable = file;
    nativeProcessStartupInfo.workingDirectory = File.desktopDirectory;

    process = new NativeProcess();
    process.start(nativeProcessStartupInfo);
    process.addEventListener(NativeProcessExitEvent.EXIT,done);

}else trace("NativeProcess NOT SUPPORTED!");

function done(e:NativeProcessExitEvent):void{
    trace("screenshot comprete");
}

One important thing to bear in mind is the AIR device profile.
If you're initially testing in ADL, be sure to use the extendedDesktop profile, otherwise NativeProcess.isSupported will return false.

For more details check out the NativeProcess documentation and the Communicating with native processes in AIR developer guide

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