gpt4 book ai didi

objective-c - 我如何在 Obj-C AppScript 中编写以下 applescript? ASTranslate 没有帮助 =(

转载 作者:行者123 更新时间:2023-12-03 18:05:30 25 4
gpt4 key购买 nike

翻译工具无法翻译此工作代码。我从工作脚本中复制了它。

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 文件,然后读取减去 header (前 512 个字节)的文件。稍后在脚本中,albumArt 将被添加到 iTunes 轨道中。

我尝试翻译代码(去掉注释),但 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

我不知道如何理解这一点。

感谢您的帮助!

最佳答案

read 是标准添加命令; ASTranslate 不支持脚本添加,仅支持可编写脚本的应用程序,因此您必须自己翻译它。

使用 ASDictionary 将标准添加字典导出为 HTML 并创建 objc-appscript 粘合 (SAGlue)。然后,您可以使用 -[SAApplication init] 创建一个新的 SAApplication 实例并向其发送 read 命令。

或者,您可以完全跳过标准添加,并使用 NSData 读取和切片文件并自行构建 NSAppleEventDescriptor。

关于objective-c - 我如何在 Obj-C AppScript 中编写以下 applescript? ASTranslate 没有帮助 =(,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2737007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com