Airアプリケーションからフルスクリーンのスナップショットを取得できるかどうか知りたいのですが。私が興味を持っているのは、WindowsのPrintScreenボタンに似た機能です。これは、Airアプリが実行されているウィンドウだけでなく、サードパーティのアプリケーションウィンドウを含むすべての画面のスナップショットを取得します。それが空気に固有ではなく、flash / flex APIがそのような機能を提供できるのであれば、それも素晴らしいでしょう。よろしくお願いします。
1730 次
1 に答える
4
この記事では、ネイティブ プロセスを呼び出してスクリーンショットを取得する方法について説明しています。
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");
}
留意すべき重要事項の 1 つは、AIR デバイス プロファイルです。最初に ADL でテストする場合は、必ずextendedDesktop
プロファイルを使用してください。そうしないと、NativeProcess.isSupported
が返されfalse
ます。
詳細については、NativeProcess のドキュメントと、AIR 開発者ガイドでのネイティブ プロセスとの通信を参照してください。
于 2010-06-07T18:36:54.067 に答える