首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >解析NSAppleEventDescriptor中的AppleScriptObjC

解析NSAppleEventDescriptor中的AppleScriptObjC
EN

Stack Overflow用户
提问于 2016-10-12 09:46:27
回答 1查看 233关注 0票数 2

我正在尝试编写一个AppleScript应用程序,以便自动控制联系人组。我正在接收一个联系人项作为脚本的输入,但是我无法理解它。到目前为止,我写的资料来源如下:

代码语言:javascript
复制
script Labels_for_contact_groups
    property parent : class "AMBundleAction"

    on runWithInput_fromAction_error_(input, anAction, errorRef)
        -- Get parameters
        set labelName to valueForKey_("trainingLabelName") of parameters() of me
        set labelValue to valueForKey_("trainingLabelValue") of parameters() of me

        -- Iterate over the contact groups
        -- what should I do here?
        log input

        return input
    end runWithInput_fromAction_error_
end script

我在日志中得到了以下内容:

代码语言:javascript
复制
2016-10-12 11:35:28.061 Automator[2167:174553] <NSAppleEventDescriptor: [ 'obj '{ 'want':'azf5', 'form':'ID  ', 'seld':'utxt'("50E8C441-3DF0-4CD7-8E36-E175B37D2CCB:ABGroup"), 'from':[0x0,10d10d "Contacts"] } ]>

我需要做的是提取指定组中所有联系人的信息。我该怎么做?

编辑:我添加了以下几行

代码语言:javascript
复制
tell application "Contacts" to set thePeople to people of input
repeat with i from 1 to number of items in thePeople
        set thisPersonCurrent to item i of thePeople
        log thisPersonCurrent
end repeat

现在,我得到以下错误:

代码语言:javascript
复制
[Labels_for_contact_groups runWithInput:fromAction:error:]: Can’t get every «class azf4» of «class ocid» id «data optr0000000080A9220080600000». (error -1728)

我做错了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-16 23:46:22

我想要达到的目标并不是通过自动程序实现的。我意识到API中有许多空白。最后起作用的是一个独立的AppleScript,它包含以下一行:

代码语言:javascript
复制
tell application "Contacts"
  set theGroupNames to name of groups
  set text_returnedCurrent to choose from list theGroupNames with prompt "Select Group" without multiple selections allowed
  set the_peopleCurrent to people of group (text_returnedCurrent as text)
  ...
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39995522

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档