可脚本(AppleScript的)在一台Mac应用碳 [英] Scriptability (AppleScript) in a Mac Carbon application

查看:174
本文介绍了可脚本(AppleScript的)在一台Mac应用碳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想补充AppleScripting我非可可基于应用程序的支持。

I am trying to add AppleScripting support to my non-Cocoa based application.

我的工作水平低的功能,如AEGetParamDesc,处理格式 / 希望 / SELD 参数喽。

I'm working the low level functions such as AEGetParamDesc, handling the form / want / seld parameters myself.

我的词汇提供了一个类,姑且称之为图像。它有一个名称属性。

My vocabulary offers a class, let's call it "Image". It has a property "name".

我已经得到了一些AppleScript的code工作,如:

I've gotten some Applescript code working, such as:

get Images
get name of every Image
get count Images
get every Image
get first Image
get Image 1

所以,基本上,访问的对象和它的属性都有效。

So, basically, access to both the objects and its properties works.

然而,当我尝试了这些类似的访问形式,他们都失败:

However, when I tried these similar access forms, they all fail:

get Images whose name = "foo"

repeat with img in Images
end repeat

在第一种情况下,看来我得处理测试的形式。

In the first case, it appears I'll have to handle a test form.

在第二种情况下,计数操作符( CNTE )不直接请求的类对象,而是使用了 cobj 运营商描述索引对象。

In the second case, the count operator (cnte) does not request the class object directly but instead uses a cobj operator describing an index object.

这一切使我不知道,这到底会去。我将必须实现单独在我的code AppleScript的每一个可能的语法和操作?我假设,其经营者只会结合起来,每一个形象,我可以写indivually他们AppleScript的,而不是使用不同的AppleEvent公式为他们每个人的路图像x的名的请求。

This all makes me wonder how far this will go. Will I have to implement every possible syntax and operator of Applescript individually in my code? I'd assume that the "whose" operator would simply combine the requests for "every Image" and "name of Image x" the way I can indivually write them in Applescript, instead of using different AppleEvent formulas for each of them.

同为的<布尔试验> 。为什么不AppleScript的简单执行名称的相等测试=富本身,因为它是一个不应有的在所有涉及我的申请code文本比较?

Same for whose <boolean-test>. Why doesn't AppleScript simply perform the equality test of name = "foo" itself, as it's a text comparison which should not have to involve my application code at all?

有我丢失的东西?我可以转发这些以AE功能,我还没有意识到的还是我来处理每一个可能的比较和流量控制命令自己?

Is there something I'm missing? Can I forward these to AE functions I'm not yet aware of or do I have to handle every possible comparison and flow control command myself?

推荐答案

托马斯Tempelmann(中发现任何文件名声?),如果你真的无法改写可可应用,这里是我多年前写了一篇文章一些细节有关的编码(C语言)的脚本化pre-可可,包括处理formWhose,你问上面。

Thomas Tempelmann (of Find Any File fame?), if you really can't rewrite the app in Cocoa, here is an article I wrote many years ago with some detail about coding (in C) for scriptability pre-Cocoa, including handling formWhose, which you asked about above.

http://www.mactech.com/articles/develop/issue_28/ reuter.html

这篇文章是由苹果公司在其开发杂志上发表,并收录源$ C ​​$ C我写了名为素描示例应用程序。这是几年前,苹果发布了自己的样本项目也命名为素描。我仍然有源$ C ​​$ C,如果它会帮助你。

The article was published by Apple in its Develop magazine, and included source code I wrote for a sample application called "Sketch". This was years before Apple released its own sample project also named "Sketch." I still have the source code if it would help you.

祝你好运!

这篇关于可脚本(AppleScript的)在一台Mac应用碳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆