How would I write the following applescript in Obj-C AppScript? ASTranslate was of no help =(
Posted
by demonslayer319
on Stack Overflow
See other posts from Stack Overflow
or by demonslayer319
Published on 2010-04-29T11:52:14Z
Indexed on
2010/04/29
11:57 UTC
Read the original article
Hit count: 448
The translation tool isn't able to translate this working code. I copied it out of a working script.
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
The code is taking a jpg image, converting it to a PICT file, and then reading the file minus the header (the first 512 bytes). Later in the script, albumArt
will be added to an iTunes track.
I tried translating the code (minus the comments), but ASTranslate froze for a good 2 minutes before giving me this:
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
I have no clue how to make sense of this.
Thanks for any and all help!
© Stack Overflow or respective owner