0

翻訳ツールは、この作業コードを翻訳できません。作業中のスクリプトからコピーしました。

set pathToTemp to (POSIX path of ((path to desktop) as string))

-- change jpg to pict
tell application "Image Events"
    try
        launch
            set albumArt to open file (pathToTemp & "albumart.jpg")
            save albumArt as PICT in file (pathToTemp & "albumart.pict")
            --the first 512 bytes are the PICT header, so it reads from byte 513
            --this is to allow the image to be added to an iTunes track later.
            set albumArt to (read file (pathToTemp & "albumart.pict") from 513 as picture)
        close
    end try
end tell

このコードは、jpg 画像を取得して PICT ファイルに変換し、ファイルからヘッダー (最初の 512 バイト) を除いて読み取ります。スクリプトの後半で、albumArtiTunes トラックに追加されます。

コードを翻訳してみました (コメントを除く) が、ASTranslate が 2 分間フリーズしてから、次のように表示されました。

Untranslated event 'earsffdr'

#import "IEGlue/IEGlue.h"
IEApplication *imageEvents = [IEApplication applicationWithName: @"Image Events"];
IELaunchCommand *cmd = [[imageEvents launch] ignoreReply];
id result = [cmd send];

#import "IEGlue/IEGlue.h"
IEApplication *imageEvents = [IEApplication applicationWithName: @"Image Events"];
IEReference *ref = [[imageEvents files] byName: @"/Users/Doom/Desktop/albumart.jpg"];
id result = [[ref open] send];

#import "IEGlue/IEGlue.h"
IEApplication *imageEvents = [IEApplication applicationWithName: @"Image Events"];
IEReference *ref = [[imageEvents images] byName: @"albumart.jpg"];
IESaveCommand *cmd = [[[ref save] in: [[imageEvents files] byName: @"/Users/Doom/Desktop/albumart.pict"]] as: [IEConstant PICT]];
id result = [cmd send];

'crdwrread'

Traceback (most recent call last):
  File "objcrenderer.pyc", line 283, in renderCommand
KeyError: 'crdwrread'


'cascrgdut'

Traceback (most recent call last):
  File "objcrenderer.pyc", line 283, in renderCommand
KeyError: 'cascrgdut'


'crdwrread'

Traceback (most recent call last):
  File "objcrenderer.pyc", line 283, in renderCommand
KeyError: 'crdwrread'


Untranslated event 'rdwrread'

OK

これを理解する方法がわかりません。

助けてくれてありがとう!

4

1 に答える 1

2

read標準追加コマンドです。ASTranslate はスクリプトの追加をサポートしておらず、スクリプト可能なアプリケーションのみをサポートしているため、自分で翻訳する必要があります。

ASDictionary を使用して Standard Additions ディクショナリを HTML にエクスポートし、objc-appscript グルー (SAGlue) を作成します。その後、-[SAApplication init] を使用して新しい SAApplication インスタンスを作成し、それにreadコマンドを送信できます。

または、Standard Additions を完全にスキップして、NSData を使用してファイルを読み取ってスライスし、NSAppleEventDescriptor を自分で構築することもできます。

于 2010-04-30T20:40:17.740 に答える