转换为Apple Events AppleScript [英] Translate into Apple Events AppleScript

查看:151
本文介绍了转换为Apple Events AppleScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的applescript:

I have an very simple applescript:

tell application "Opera"
   get URL of active tab of window 1
end tell

我想查看Apple Events的基础.因此,我在启用以下两个环境变量的情况下启动了它:

I want to see Apple Events underlying. So I have launched it with these two environment variables enabled:

export AEDebugSends=1;
export AEDebugReceives=1

现在我得到以下输出:

osascript browser.scpt 
{core,getd target='psn '[Opera] {----={form=prop,want=prop,seld=URL ,from={form=prop,want=prop,seld=acTa,from={form=indx,want=cwin,seld=1,from=NULL-impl}}}} attr:{csig=65536 returnID=15130}

我希望看到对此处定义的函数的调用: https://developer.apple.com/documentation/coreservices/apple_events?language=objc

I would expect to see calls to functions defined here: https://developer.apple.com/documentation/coreservices/apple_events?language=objc

我的最终目标是将Applescript转换为c或Obj-C代码.

My final goal is to translate that Applescript into c or Obj-C code.

有人可以帮助我理解输出的含义吗?

Could someone help me to understand the meaning of the output?

预先感谢

推荐答案

希望看到对此处定义的函数的调用

would expect to see calls to functions defined here

好吧,别再期待了.您所拥有的是Apple事件本身,以AEPrint表示法表示,如下所述:

Well, stop expecting that. What you have is the Apple event itself, expressed in AEPrint notation, as explained here:

https://developer.apple.com/library/archive/technotes/tn/tn2045.html

您可以使用它来构造相同的Apple事件,也可以使用更高级别的命令将其分成多个部分.但是无论哪种方式,都没有系统为您编写代码!那是由AppleScript为您构建的Apple事件.学习如何阅读AEPrint表示法,学习Apple事件的结构,学习手工构建相同的Apple事件,这些都是您必须自己做的事情.

You can use that to construct the same Apple event, or you can form it in pieces using higher level commands. But either way, it is not up to the system to write your code for you! That is the Apple event, built for you by AppleScript. Learning to read AEPrint notation, learning the structure of an Apple event, learning to build the same Apple event by hand, is all something you must do yourself.

仅举一个您将使用的推理示例:

Just to give an example of the reasoning you will use:

  • 您的Apple事件以动词coregetd开头.通过在应用程序的SDEF字典中查找,您可以了解到与get(AppleScript中的第一个单词)等效的Apple事件.

  • Your Apple event starts with the verb coregetd. That is the Apple event equivalent of get (the first word in your AppleScript), as you learn from looking in the application's SDEF dictionary.

好的,现在我们知道动词了;直接的对象是什么?这是一个URL (请注意空格,这些是四个字母的代码);这相当于您的URL的Apple事件(同样,我们通过词典来学习).

OK, now we know the verb; what's the direct object? It's an URL  (note the space, these are four-letter codes); that is the Apple event equivalent of your URL (again, we learn this through the dictionary).

好,但是URL是什么?它是acTaURL,也就是active tab(同样,字典向我们展示了这种等效性).

OK, but what URL? It's the URL of the acTa, which is the active tab (again, the dictionary shows us this equivalence).

好,但是acTa是什么? ...

OK, but the acTa of what? ...

以此类推.通过这种方式将Apple事件分解为属性,元素和对象说明符后,您可以通过Carbon或Cocoa命令再次构建它.

And so on. Once you have broken down the Apple event into properties and elements and objects specifiers in this way, you can build it up again through Carbon or Cocoa commands.

出于逃避我的原因,您选择了漫长的旅程.您已选择放弃AppleScript表示法的简单性,并自己构建一个Apple事件.您选择了一条漫长的道路,需要学习很多东西.没有捷径可走.运行时不会为您编写代码.最长的旅程从第一步开始.开始!

You have chosen, for reasons that escape me, to embark on a very long journey. You have elected to throw away the simplicity of AppleScript notation and construct an Apple event yourself. You have chosen a long road involving much learning. There is no shortcut; the runtime is not going to write your code for you. The longest journey begins with the first step. Begin!

这篇关于转换为Apple Events AppleScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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